diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 4c74a0b834..b676df3b85 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -163,9 +163,7 @@ QWindow::QWindow(QScreen *targetScreen) //if your applications aborts here, then chances are your creating a QWindow before the //screen list is populated. Q_ASSERT(d->screen); - - connect(d->screen, SIGNAL(destroyed(QObject*)), this, SLOT(screenDestroyed(QObject*))); - QGuiApplicationPrivate::window_list.prepend(this); + d->init(); } /*! @@ -188,8 +186,7 @@ QWindow::QWindow(QWindow *parent) 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); + d->init(); } /*! @@ -214,8 +211,7 @@ QWindow::QWindow(QWindowPrivate &dd, QWindow *parent) 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); + d->init(); } /*! @@ -233,6 +229,13 @@ QWindow::~QWindow() destroy(); } +void QWindowPrivate::init() +{ + Q_Q(QWindow); + QObject::connect(screen, SIGNAL(destroyed(QObject*)), q, SLOT(screenDestroyed(QObject*))); + QGuiApplicationPrivate::window_list.prepend(q); +} + /*! \enum QWindow::Visibility \since 5.1 diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index 8ebbf5d508..4305edea51 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -108,6 +108,8 @@ public: { } + void init(); + void maybeQuitOnLastWindowClosed(); #ifndef QT_NO_CURSOR void setCursor(const QCursor *c = 0);