diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-08-22 10:17:12 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-08-25 12:00:28 +0000 |
commit | fd785c3899d21dd05fd013336bbc63ce818dc2a6 (patch) | |
tree | 553dd288e83b5f984f04c2c8609ffb8b8eace2b4 /src/corelib/global/qlogging.cpp | |
parent | 0d336ab3132c85781fc62b9d92dce690b8ff9d59 (diff) |
QtCore: port all QMutexLocker users to qt_{scoped,unique}_lock
... except four instances in QCoreApplication that would conflict with
another change.
Replace a locally-defined MutexUnlocker with a call to unlock() +
qScopedGuard'ed lock() to avoid having to spell out the locker type
while we can't depend on C++17 CTAD, yet.
In QSettings, move the new mutex locker into and out of
initDefaultPaths(), such as is idiomatic for std::unique_lock, but
wasn't possible with QMutexLocker (which is not movable).
Change-Id: I23056e13ecaa76159db583c7dccc6e05715e0788
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/global/qlogging.cpp')
-rw-r--r-- | src/corelib/global/qlogging.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 621b6d7d13..491823f217 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -49,6 +49,7 @@ #include "qvarlengtharray.h" #include "qdebug.h" #include "qmutex.h" +#include <QtCore/private/qlocking_p.h> #include "qloggingcategory.h" #ifndef QT_BOOTSTRAPPED #include "qelapsedtimer.h" @@ -1375,7 +1376,7 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con { QString message; - QMutexLocker lock(&QMessagePattern::mutex); + const auto locker = qt_scoped_lock(QMessagePattern::mutex); QMessagePattern *pattern = qMessagePattern(); if (!pattern) { @@ -2091,7 +2092,7 @@ QtMsgHandler qInstallMsgHandler(QtMsgHandler h) void qSetMessagePattern(const QString &pattern) { - QMutexLocker lock(&QMessagePattern::mutex); + const auto locker = qt_scoped_lock(QMessagePattern::mutex); if (!qMessagePattern()->fromEnvironment) qMessagePattern()->setPattern(pattern); |