Переглянути джерело

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.
Andreas Kling 4 роки тому
батько
коміт
e64f43c3a7
1 змінених файлів з 4 додано та 2 видалено
  1. 4 2
      Libraries/LibGUI/Widget.cpp

+ 4 - 2
Libraries/LibGUI/Widget.cpp

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