Clarify QWindowPrivate::maybeQuitOnLastWindowClosed

We only need to check QGuiApplication::quitOnLastWindowClosed() at
the point where we've actually concluded that the last window was
closed.

Checking for !q->parent() was redundant, as we were already
exiting early when !q->isTopLevel().

Change-Id: I934e186d707361b31d19692c04d2e17b7ba0f49e
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 1649137b9311a5ee3d12bc8824f5453294bd6fe9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2020-12-10 16:06:53 +01:00 committed by Qt Cherry-pick Bot
parent acf00dd72d
commit a0d963f436

View File

@ -2776,8 +2776,7 @@ void QWindowPrivate::maybeQuitOnLastWindowClosed()
Q_Q(QWindow);
if (!q->isTopLevel())
return;
// Attempt to close the application only if this has WA_QuitOnClose set and a non-visible parent
bool quitOnClose = QGuiApplication::quitOnLastWindowClosed() && !q->parent();
QWindowList list = QGuiApplication::topLevelWindows();
bool lastWindowClosed = true;
for (int i = 0; i < list.size(); ++i) {
@ -2789,7 +2788,8 @@ void QWindowPrivate::maybeQuitOnLastWindowClosed()
}
if (lastWindowClosed) {
QGuiApplicationPrivate::emitLastWindowClosed();
if (quitOnClose) {
if (QGuiApplication::quitOnLastWindowClosed()) {
QCoreApplicationPrivate *applicationPrivate = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(QCoreApplication::instance()));
applicationPrivate->maybeQuit();
}