diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-01-31 17:19:06 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-03-26 17:15:02 +0100 |
commit | 80b6bcc385863a38d499685af9b8e857e46cbdba (patch) | |
tree | 252b745a2b8dd617224f49cf89139cd5baef317c /src/dbus/qdbusintegrator.cpp | |
parent | edb64351cd0896d27af15d54d5fa868c7567eced (diff) |
Short live Q_CONSTINIT!
It expands to the first available of
- constinit (C++20)
- [[clang::require_constant_initialization]] (Clang)
- __constinit (GCC >= 10)
Use it around the code (on and near static QBasicAtomic; this patch
makes no attempt to find all statics in qtbase).
[ChangeLog][QtCore][QtGlobal] Added macro Q_CONSTINIT.
Fixes: QTBUG-100484
Change-Id: I11e0363a7acb3464476859d12ec7f94319d82be7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/dbus/qdbusintegrator.cpp')
-rw-r--r-- | src/dbus/qdbusintegrator.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 7efd94ac77..9ddaf8d4c1 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1991,14 +1991,14 @@ public: #if defined(QT_NO_DEBUG) // when in a release build, we default these to off. // this means that we only affect code that explicitly enables the warning. - static int mainThreadWarningAmount = -1; - static int otherThreadWarningAmount = -1; + Q_CONSTINIT static int mainThreadWarningAmount = -1; + Q_CONSTINIT static int otherThreadWarningAmount = -1; #else - static int mainThreadWarningAmount = 200; - static int otherThreadWarningAmount = 500; + Q_CONSTINIT static int mainThreadWarningAmount = 200; + Q_CONSTINIT static int otherThreadWarningAmount = 500; #endif - static bool initializedAmounts = false; - static QBasicMutex initializeMutex; + Q_CONSTINIT static bool initializedAmounts = false; + Q_CONSTINIT static QBasicMutex initializeMutex; auto locker = qt_unique_lock(initializeMutex); if (!initializedAmounts) { |