summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/Widget.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-03-05 15:30:11 +0100
committerAndreas Kling <kling@serenityos.org>2020-03-05 15:48:57 +0100
commit4d5e144a6ba6601e5fe8f9a75d677f4cdd616473 (patch)
tree75f10b846d6ee2cfa54bd33cf19b09101094661a /Libraries/LibGUI/Widget.cpp
parente23c5b7e83fe6de92f5d4796ea50e368002a2d2e (diff)
downloadserenity-4d5e144a6ba6601e5fe8f9a75d677f4cdd616473.zip
LibGUI: Forget some of Window's widgets eagerly on widget unparenting
Previously the focused widget would only get cleared on replacement or on destruction (being a WeakPtr and all.) This could lead to window dispatching events to a focused widget after it had been removed from the window's widget tree. The same issue existed for the hovered widget, etc. So this patch makes sure that we eagerly clear the various widget pointers in Window immediately when they are removed from the window's widget tree.
Diffstat (limited to 'Libraries/LibGUI/Widget.cpp')
-rw-r--r--Libraries/LibGUI/Widget.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/Libraries/LibGUI/Widget.cpp b/Libraries/LibGUI/Widget.cpp
index b225598d5a..6b41646092 100644
--- a/Libraries/LibGUI/Widget.cpp
+++ b/Libraries/LibGUI/Widget.cpp
@@ -123,6 +123,8 @@ void Widget::child_event(Core::ChildEvent& event)
else
invalidate_layout();
}
+ if (event.child() && Core::is<Widget>(*event.child()))
+ window()->did_remove_widget({}, Core::to<Widget>(*event.child()));
update();
}
return Core::Object::child_event(event);