QEventLoop: fix potential UB in QBasicAtomic initialization

Until C++17 (inclusive), a default-constructed std::atomic object can,
officially, only be initialized with a call to std::atomic_init, for
which QBasicAtomic doesn't have API. It is even unclear whether
zero-initialization of static and thread-local objects will cause the
object to be initialized.

To fix, port from QBasicAtomic to QAtomic (which initializes to zero).

Task-number: QTBUG-137465
Pick-to: 6.8 6.5
Change-Id: I31a95b36506c376ef0817ef3d61bd8ca02371585
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 8f4ffb72f9e49702f878222b785cf0efc871ee9c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 2d55125018a24a19dc07e317c06179dd083e8694)
This commit is contained in:
Marc Mutz 2025-06-06 16:40:48 +02:00 committed by Qt Cherry-pick Bot
parent 80aef94a42
commit e6c5e03d61

View File

@ -34,8 +34,8 @@ public:
QAtomicInt quitLockRef;
QBasicAtomicInt exit; // bool
QBasicAtomicInt returnCode;
QAtomicInt exit; // bool
QAtomicInt returnCode;
bool inExec;
void ref()