diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2021-12-14 09:03:55 -0300 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2022-01-05 17:03:45 -0300 |
commit | e3e2674100b1ecbad7117f15c7aa13a704a7d34e (patch) | |
tree | 6eb5d7fbb46e5476691e84ead9da6682b0131088 /src/corelib/global | |
parent | 602a186cb4fe673edd394682b822cec0ca85d0d3 (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.
Pick-to: 6.3
Fixes: QTBUG-99192
Change-Id: Ib42b3adc93bf4d43bd55fffd16c09d7f835d121e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/global')
-rw-r--r-- | src/corelib/global/qglobalstatic.h | 4 |
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 |