summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2021-12-14 09:03:55 -0300
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-01-06 01:12:05 +0000
commit4b8938f3be7e73ca9badf427d465620a9988efea (patch)
treefd5bc81fac84b525594ee88465a980f705dcd49c
parent8343d63475c2a54f81df265af8bca739ce9d981f (diff)
QGlobalStatic: invert the order of destruction and setting the guard
This is how the old implementation did it: the Type member was a member of Holder, but the guard was set to Destroyed in the HolderBase destructor, which ran after. I find the way I implemented in commit81a31beeb25eaf14d5c5f42fe26aa49d6ef29bf8 to be more natural, but it caused regressions at runtime for code that attempted to reenter the global static on destruction. Not unit-tested because I don't know if we want to keep this forever. Fixes: QTBUG-99192 Change-Id: Ib42b3adc93bf4d43bd55fffd16c09d7f835d121e Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit e3e2674100b1ecbad7117f15c7aa13a704a7d34e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/corelib/global/qglobalstatic.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h
index 098aee966b..1e35cb29f0 100644
--- a/src/corelib/global/qglobalstatic.h
+++ b/src/corelib/global/qglobalstatic.h
@@ -76,9 +76,9 @@ template <typename QGS> union Holder
~Holder()
{
- guard.storeRelaxed(QtGlobalStatic::Destroyed);
- std::atomic_thread_fence(std::memory_order_acquire); // avoid mixing stores to guard and *pointer()
pointer()->~PlainType();
+ std::atomic_thread_fence(std::memory_order_acquire); // avoid mixing stores to guard and *pointer()
+ guard.storeRelaxed(QtGlobalStatic::Destroyed);
}
PlainType *pointer() noexcept