mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:38:10 +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:
parent
e23c5b7e83
commit
4d5e144a6b
3 changed files with 16 additions and 0 deletions
|
@ -689,4 +689,16 @@ void Window::set_size_increment(const Gfx::Size& size_increment)
|
|||
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowBaseSizeAndSizeIncrement>(m_window_id, m_base_size, m_size_increment);
|
||||
}
|
||||
|
||||
void Window::did_remove_widget(Badge<Widget>, const Widget& widget)
|
||||
{
|
||||
if (m_focused_widget == &widget)
|
||||
m_focused_widget = nullptr;
|
||||
if (m_hovered_widget == &widget)
|
||||
m_hovered_widget = nullptr;
|
||||
if (m_global_cursor_tracking_widget)
|
||||
m_global_cursor_tracking_widget = nullptr;
|
||||
if (m_automatic_cursor_tracking_widget)
|
||||
m_automatic_cursor_tracking_widget = nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue