summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qlogging.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-01-31 17:19:06 +0100
committerMarc Mutz <marc.mutz@qt.io>2022-03-26 17:15:02 +0100
commit80b6bcc385863a38d499685af9b8e857e46cbdba (patch)
tree252b745a2b8dd617224f49cf89139cd5baef317c /src/corelib/global/qlogging.cpp
parentedb64351cd0896d27af15d54d5fa868c7567eced (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/corelib/global/qlogging.cpp')
-rw-r--r--src/corelib/global/qlogging.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 254894961e..6302fc9d80 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -1096,7 +1096,7 @@ struct QMessagePattern
Q_DECLARE_TYPEINFO(QMessagePattern::BacktraceParams, Q_RELOCATABLE_TYPE);
#endif
-QBasicMutex QMessagePattern::mutex;
+Q_CONSTINIT QBasicMutex QMessagePattern::mutex;
QMessagePattern::QMessagePattern()
{
@@ -1750,7 +1750,7 @@ static bool android_default_message_handler(QtMsgType type,
static void win_outputDebugString_helper(const QString &message)
{
const qsizetype maxOutputStringLength = 32766;
- static QBasicMutex m;
+ Q_CONSTINIT static QBasicMutex m;
auto locker = qt_unique_lock(m);
// fast path: Avoid string copies if one output is enough
if (message.length() <= maxOutputStringLength) {
@@ -1827,7 +1827,7 @@ static void stderr_message_handler(QtMsgType type, const QMessageLogContext &con
#ifdef Q_OS_WASM
// Prevent thread cross-talk, which causes Emscripten to log
// non-valid UTF-8. FIXME: remove once we upgrade to emsdk > 2.0.30
- static QBasicMutex m;
+ Q_CONSTINIT static QBasicMutex m;
auto locker = qt_unique_lock(m);
#endif