From fc060c472d728a681f623ce17676078c8262bc7e Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 30 Jan 2014 10:29:09 +0100 Subject: [PATCH] QWindow: reduce a bit of code duplication. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Makes it easier to add code in the future too. No-op change. Change-Id: I228c36813ccf8ee95ed4b6cbbc20af3178d1b84a Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qwindow.cpp | 17 ++++++++++------- src/gui/kernel/qwindow_p.h | 2 ++ 2 files changed, 12 insertions(+), 7 deletions(-) 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);