Do not crash when closing pop-ups in widget apps.
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>
Fri, 13 Apr 2012 08:57:22 +0000 (11:57 +0300)
committerJørgen Lind <jorgen.lind@nokia.com>
Tue, 17 Apr 2012 11:08:40 +0000 (13:08 +0200)
The shm frame callback has to be destroyed otherwise the callback will
occur after the dtor. Also, start using the previously unused 'window'
variable in the callback.

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

index 0d4d06f..5858f24 100644 (file)
@@ -135,6 +135,9 @@ QWaylandShmBackingStore::QWaylandShmBackingStore(QWindow *window)
 
 QWaylandShmBackingStore::~QWaylandShmBackingStore()
 {
+    if (mFrameCallback)
+        wl_callback_destroy(mFrameCallback);
+
 //    if (mFrontBuffer == waylandWindow()->attached())
 //        waylandWindow()->attach(0);
 
@@ -269,16 +272,16 @@ void QWaylandShmBackingStore::done(void *data, wl_callback *callback, uint32_t t
     QWaylandWindow *window = self->waylandWindow();
     wl_callback_destroy(self->mFrameCallback);
     self->mFrameCallback = 0;
-    if (self->mFrontBuffer != self->waylandWindow()->attached()) {
-        delete self->waylandWindow()->attached();
-        self->waylandWindow()->attach(self->mFrontBuffer);
+    if (self->mFrontBuffer != window->attached()) {
+        delete window->attached();
+        window->attach(self->mFrontBuffer);
     }
 
     if (self->mFrontBufferIsDirty && !self->mPainting) {
         self->mFrontBufferIsDirty = false;
-        self->mFrameCallback = wl_surface_frame(self->waylandWindow()->wl_surface());
+        self->mFrameCallback = wl_surface_frame(window->wl_surface());
         wl_callback_add_listener(self->mFrameCallback,&self->frameCallbackListener,self);
-        self->waylandWindow()->damage(QRect(QPoint(0,0),self->mFrontBuffer->size()));
+        window->damage(QRect(QPoint(0,0),self->mFrontBuffer->size()));
     }
 }