Prevent crashing on screen deletion.
authorSamuel Rødal <samuel.rodal@digia.com>
Mon, 1 Oct 2012 08:10:08 +0000 (10:10 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 8 Oct 2012 07:01:41 +0000 (09:01 +0200)
Even child windows need to hook into the screen destroyed signal to
avoid having a dangling screen pointer.

Change-Id: I7b613356c333be6e9dfdf5db45f70a521a9b8fe2
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
src/gui/kernel/qwindow.cpp

index 1e2ac5b..79927cb 100644 (file)
@@ -177,6 +177,7 @@ QWindow::QWindow(QWindow *parent)
         d->screen = parent->screen();
     if (!d->screen)
         d->screen = QGuiApplication::primaryScreen();
         d->screen = parent->screen();
     if (!d->screen)
         d->screen = QGuiApplication::primaryScreen();
+    connect(d->screen, SIGNAL(destroyed(QObject*)), this, SLOT(screenDestroyed(QObject*)));
     QGuiApplicationPrivate::window_list.prepend(this);
 }
 
     QGuiApplicationPrivate::window_list.prepend(this);
 }
 
@@ -202,6 +203,7 @@ QWindow::QWindow(QWindowPrivate &dd, QWindow *parent)
         d->screen = parent->screen();
     if (!d->screen)
         d->screen = QGuiApplication::primaryScreen();
         d->screen = parent->screen();
     if (!d->screen)
         d->screen = QGuiApplication::primaryScreen();
+    connect(d->screen, SIGNAL(destroyed(QObject*)), this, SLOT(screenDestroyed(QObject*)));
     QGuiApplicationPrivate::window_list.prepend(this);
 }
 
     QGuiApplicationPrivate::window_list.prepend(this);
 }