summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qcoreapplication.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2021-03-14 09:48:00 -0700
committerThiago Macieira <thiago.macieira@intel.com>2021-04-09 18:10:00 +0000
commit183df80b9c1439202ae6b967774123cb313e9097 (patch)
tree63f9024530d20bda12ba4f03c2d2303f5954ea98 /src/corelib/kernel/qcoreapplication.cpp
parent2e6c37fe51b5f6073db0c7335c4a4272269d482f (diff)
QCoreApplication: improve docs on exit() and quit() thread-safety
Reporter of QTBUG-91771 was confused. Pick-to: 6.1 Change-Id: I26b8286f61534f88b649fffd166c4368167a5638 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/kernel/qcoreapplication.cpp')
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index ccdece6357..5ea01ec53d 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -1399,6 +1399,12 @@ void QCoreApplicationPrivate::execCleanup()
function \e does return to the caller -- it is event processing that
stops.
+ Note also that this function is not thread-safe. It should be called only
+ from the main thread (the thread that the QCoreApplication object is
+ processing events on). To ask the application to exit from another thread,
+ either use QCoreApplication::quit() or instead call this function from the
+ main thread with QMetaMethod::invokeMethod().
+
\sa quit(), exec()
*/
void QCoreApplication::exit(int returnCode)
@@ -1950,6 +1956,8 @@ void QCoreApplicationPrivate::maybeQuit()
}
/*!
+ \threadsafe
+
Asks the application to quit.
The request may be ignored if the application prevents the quit,
@@ -1961,7 +1969,7 @@ void QCoreApplicationPrivate::maybeQuit()
code 0 (success).
To exit the application without a chance of being interrupted, call
- exit() directly.
+ exit() directly. Note that method is not thread-safe.
It's good practice to always connect signals to this slot using a
\l{Qt::}{QueuedConnection}. If a signal connected (non-queued) to this slot
@@ -1974,6 +1982,11 @@ void QCoreApplicationPrivate::maybeQuit()
\snippet code/src_corelib_kernel_qcoreapplication.cpp 1
+ \b{Thread-safety note}: this function may be called from any thread to
+ thread-safely cause the currently-running main application loop to exit.
+ However, thread-safety is not guaranteed if the QCoreApplication object is
+ being destroyed at the same time.
+
\sa exit(), aboutToQuit()
*/
void QCoreApplication::quit()