diff options
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 11 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication_p.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 20 |
3 files changed, 22 insertions, 11 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index ea562c75b8..9f7bc24119 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -107,8 +107,6 @@ int QGuiApplicationPrivate::mousePressX = 0; int QGuiApplicationPrivate::mousePressY = 0; int QGuiApplicationPrivate::mouse_double_click_distance = 5; -bool QGuiApplicationPrivate::quitOnLastWindowClosed = true; - static Qt::LayoutDirection layout_direction = Qt::LeftToRight; static bool force_reverse = false; @@ -1388,14 +1386,14 @@ void QGuiApplicationPrivate::notifyActiveWindowChange(QWindow *) void QGuiApplication::setQuitOnLastWindowClosed(bool quit) { - QGuiApplicationPrivate::quitOnLastWindowClosed = quit; + QCoreApplication::setQuitLockEnabled(quit); } bool QGuiApplication::quitOnLastWindowClosed() { - return QGuiApplicationPrivate::quitOnLastWindowClosed; + return QCoreApplication::isQuitLockEnabled(); } @@ -1403,11 +1401,6 @@ bool QGuiApplication::quitOnLastWindowClosed() void QGuiApplicationPrivate::emitLastWindowClosed() { if (qGuiApp && qGuiApp->d_func()->in_exec) { - if (QGuiApplicationPrivate::quitOnLastWindowClosed) { - // get ready to quit, this event might be removed if the - // event loop is re-entered, however - QGuiApplication::postEvent(qApp, new QEvent(QEvent::Quit)); - } emit qGuiApp->lastWindowClosed(); } } diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 6d3e650c32..2f1cfa509d 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -183,8 +183,6 @@ public: QStyleHints *styleHints; QInputPanel *inputPanel; - static bool quitOnLastWindowClosed; - static QList<QObject *> generic_plugin_list; #ifndef QT_NO_SHORTCUT QShortcutMap shortcutMap; diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index e85d8379fa..4436884359 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -165,6 +165,14 @@ void QWindow::setVisible(bool visible) return; d->visible = visible; emit visibleChanged(visible); + if (QCoreApplication::instance() && !transientParent()) { + QCoreApplicationPrivate *applicationPrivate = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(QCoreApplication::instance())); + if (visible) { + applicationPrivate->ref(); + } else { + applicationPrivate->deref(); + } + } if (!d->platformWindow) create(); @@ -499,7 +507,19 @@ void QWindow::setWindowState(Qt::WindowState state) void QWindow::setTransientParent(QWindow *parent) { Q_D(QWindow); + + QWindow *previousParent = d->transientParent; + d->transientParent = parent; + + if (QCoreApplication::instance() && d->visible) { + QCoreApplicationPrivate *applicationPrivate = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(QCoreApplication::instance())); + if (parent && !previousParent) { + applicationPrivate->deref(); + } else if (!parent && previousParent) { + applicationPrivate->ref(); + } + } } QWindow *QWindow::transientParent() const |