From a0d963f43607f8719e450b572329daae8de42640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 10 Dec 2020 16:06:53 +0100 Subject: [PATCH] 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 (cherry picked from commit 1649137b9311a5ee3d12bc8824f5453294bd6fe9) Reviewed-by: Qt Cherry-pick Bot --- src/gui/kernel/qwindow.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 544849a197b..d93f43a3104 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -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(QObjectPrivate::get(QCoreApplication::instance())); applicationPrivate->maybeQuit(); }