From 851ed6f0b1014e5acabdc1f977979841d16ecc31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 8 Nov 2021 16:57:24 +0100 Subject: [PATCH] Don't quit application if we're not in exec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The documentation states that the function will not have any effect before control enters the main event loop. Prior to 0c02f133f3daee1 this was incidentally true due to QCoreApplication::exit just setting quitNow to true and exiting all the event loops (which before exec were none), and exec() setting quitNow to false explicitly. But now that we plumb the quit down to the platform we can't rely on this incidental behavior, and need to check explicitly. Fixes: QTBUG-98088 Pick-to: 6.2 Change-Id: I54cece3630e39e4456abc3b372839c0b5c4c4713 Reviewed-by: Timur Pocheptsov Reviewed-by: Morten Johan Sørvig --- src/corelib/kernel/qcoreapplication.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index ff23623e9a0..bd2da0760d5 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -2051,6 +2051,9 @@ void QCoreApplication::quit() if (!self) return; + if (!self->d_func()->in_exec) + return; + self->d_func()->quit(); }