LibGUI: Fix null pointer dereference in enter/leave event handling

If an enter/leave event is delivered to a widget after it is removed
from a window, we can't just assume a window is gonna be there.

Fixes #3669.
This commit is contained in:
Andreas Kling 2020-10-03 19:43:46 +02:00
parent 3b2120e7b6
commit e64f43c3a7
Notes: sideshowbarker 2024-07-19 02:05:12 +09:00

View file

@ -342,14 +342,16 @@ void Widget::handle_mousedoubleclick_event(MouseEvent& event)
void Widget::handle_enter_event(Core::Event& event)
{
window()->update_cursor({});
if (auto* window = this->window())
window->update_cursor({});
show_tooltip();
enter_event(event);
}
void Widget::handle_leave_event(Core::Event& event)
{
window()->update_cursor({});
if (auto* window = this->window())
window->update_cursor({});
Application::the()->hide_tooltip();
leave_event(event);
}