From b11f2ccc5b45e78164d523684f24d29b6e1b7490 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 28 Oct 2024 15:04:38 +0100 Subject: [PATCH] Correct QGlobalStatic<>::exists() documentation The documentation claimed that exists() would return true even after destruction. This was not true when this implementation of QGS was introduced by commit f7eff7251786186ca895c8fc537b304bc89977b3. The docs in commit c0860d26a1b87f42842faeda3e6043a775916594, however, claimed it and no-one seems to have noticed the error until now. Both commits first landed in Qt 5.1. Pick-to: 6.5 6.2 5.15 Change-Id: Ic92c8ead25faed0125ff583cb76420a4154af9df Reviewed-by: Thiago Macieira (cherry picked from commit e9226e6e44419affb13ebdd9c624ea8ef357dc2c) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/global/qglobalstatic.qdoc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/corelib/global/qglobalstatic.qdoc b/src/corelib/global/qglobalstatic.qdoc index 38700032b18..a6f9e756f48 100644 --- a/src/corelib/global/qglobalstatic.qdoc +++ b/src/corelib/global/qglobalstatic.qdoc @@ -246,7 +246,7 @@ The QGlobalStatic::exists() and QGlobalStatic::isDestroyed() functions operate solely on the guard variable: the former returns \c true if the guard - is negative, whereas the latter returns \c true only if it is -2. + is -1, the latter returns \c true if it is -2. \endomit @@ -359,12 +359,13 @@ This function returns \c true if the global static object has already completed initialization (that is, if the constructor for the type has - already returned). In specific, note that this function returns \c false if - the initialization is still in progress. + already returned) and has not yet completed destruction. In particular, note + that this function returns \c false if the initialization is still in + progress. Once this function has returned true once, it will never return false again - until either the program is restarted or the plugin or library containing - the global static is unloaded and reloaded. + until the global static object is destroyed. The latter happens on program + exit or when the plugin or library containing the global static is unloaded. This function is safe to call at any point in the program execution: it cannot fail and cannot cause a deadlock. Additionally, it will not cause