1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00

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.
This commit is contained in:
Andreas Kling 2020-03-05 15:30:11 +01:00
parent e23c5b7e83
commit 4d5e144a6b
3 changed files with 16 additions and 0 deletions

View file

@ -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);