Do not assert when closing dialogs
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>
Fri, 13 Apr 2012 09:22:14 +0000 (12:22 +0300)
committerJørgen Lind <jorgen.lind@nokia.com>
Tue, 17 Apr 2012 11:09:16 +0000 (13:09 +0200)
The leave event may arrive after the window is gone, resulting in a
null surface. The callback should do nothing in this case.

Change-Id: I36ec4cb1615f518de57b7de98206cdb8986405e4
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
src/plugins/platforms/wayland/qwaylandinputdevice.cpp

index 2be5946..7ac47f9 100644 (file)
@@ -362,7 +362,7 @@ void QWaylandInputDevice::inputHandlePointerEnter(void *data,
     Q_UNUSED(sy);
     QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
 
-    // shouldn't get pointer leave with no surface
+    // shouldn't get pointer enter with no surface
     Q_ASSERT(surface);
 
     QWaylandWindow *window = (QWaylandWindow *) wl_surface_get_user_data(surface);
@@ -379,8 +379,10 @@ void QWaylandInputDevice::inputHandlePointerLeave(void *data,
     Q_UNUSED(input_device);
     QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
 
-    // shouldn't get pointer leave with no surface
-    Q_ASSERT(surface);
+    // The event may arrive after destroying the window, indicated by
+    // a null surface.
+    if (!surface)
+        return;
 
     QWaylandWindow *window = (QWaylandWindow *) wl_surface_get_user_data(surface);
     window->handleMouseLeave();