summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qloggingregistry.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-08-22 10:17:12 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-08-25 12:00:28 +0000
commitfd785c3899d21dd05fd013336bbc63ce818dc2a6 (patch)
tree553dd288e83b5f984f04c2c8609ffb8b8eace2b4 /src/corelib/io/qloggingregistry.cpp
parent0d336ab3132c85781fc62b9d92dce690b8ff9d59 (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/io/qloggingregistry.cpp')
-rw-r--r--src/corelib/io/qloggingregistry.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp
index 7849dfd14c..e8eb18b4c1 100644
--- a/src/corelib/io/qloggingregistry.cpp
+++ b/src/corelib/io/qloggingregistry.cpp
@@ -41,6 +41,7 @@
#include <QtCore/qfile.h>
#include <QtCore/qlibraryinfo.h>
+#include <QtCore/private/qlocking_p.h>
#include <QtCore/qstandardpaths.h>
#include <QtCore/qtextstream.h>
#include <QtCore/qdir.h>
@@ -356,7 +357,7 @@ void QLoggingRegistry::initializeRules()
*/
void QLoggingRegistry::registerCategory(QLoggingCategory *cat, QtMsgType enableForLevel)
{
- QMutexLocker locker(&registryMutex);
+ const auto locker = qt_scoped_lock(registryMutex);
if (!categories.contains(cat)) {
categories.insert(cat, enableForLevel);
@@ -370,7 +371,7 @@ void QLoggingRegistry::registerCategory(QLoggingCategory *cat, QtMsgType enableF
*/
void QLoggingRegistry::unregisterCategory(QLoggingCategory *cat)
{
- QMutexLocker locker(&registryMutex);
+ const auto locker = qt_scoped_lock(registryMutex);
categories.remove(cat);
}
@@ -413,7 +414,7 @@ void QLoggingRegistry::updateRules()
QLoggingCategory::CategoryFilter
QLoggingRegistry::installFilter(QLoggingCategory::CategoryFilter filter)
{
- QMutexLocker locker(&registryMutex);
+ const auto locker = qt_scoped_lock(registryMutex);
if (!filter)
filter = defaultCategoryFilter;