From 730893c123cf30a94a494f1d292478d98f6095af Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 23 Jul 2019 18:37:34 +0300 Subject: [PATCH] QResource: port from QMutexLocker to qt_scoped_lock Change-Id: I483e4765ef83d13e81bb830c9f48421410c5718b Reviewed-by: Thiago Macieira --- src/corelib/io/qresource.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index 52b746d04a..22c22ce711 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -42,7 +42,7 @@ #include "qresource_p.h" #include "qresource_iterator_p.h" #include "qset.h" -#include "qmutex.h" +#include #include "qdebug.h" #include "qlocale.h" #include "qglobal.h" @@ -203,8 +203,8 @@ struct QResourceGlobalData }; Q_GLOBAL_STATIC(QResourceGlobalData, resourceGlobalData) -static inline QRecursiveMutex *resourceMutex() -{ return &resourceGlobalData->resourceMutex; } +static inline QRecursiveMutex &resourceMutex() +{ return resourceGlobalData->resourceMutex; } static inline ResourceList *resourceList() { return &resourceGlobalData->resourceList; } @@ -337,7 +337,7 @@ bool QResourcePrivate::load(const QString &file) { related.clear(); - QMutexLocker lock(resourceMutex()); + const auto locker = qt_scoped_lock(resourceMutex()); const ResourceList *list = resourceList(); QString cleaned = cleanPath(file); for(int i = 0; i < list->size(); ++i) { @@ -392,7 +392,7 @@ QResourcePrivate::ensureInitialized() const if(path.startsWith(QLatin1Char('/'))) { that->load(path.toString()); } else { - QMutexLocker lock(resourceMutex()); + const auto locker = qt_scoped_lock(resourceMutex()); QStringList searchPaths = *resourceSearchPaths(); searchPaths << QLatin1String(""); for(int i = 0; i < searchPaths.size(); ++i) { @@ -688,7 +688,7 @@ QResource::addSearchPath(const QString &path) path.toLocal8Bit().data()); return; } - QMutexLocker lock(resourceMutex()); + const auto locker = qt_scoped_lock(resourceMutex()); resourceSearchPaths()->prepend(path); } @@ -706,7 +706,7 @@ QResource::addSearchPath(const QString &path) QStringList QResource::searchPaths() { - QMutexLocker lock(resourceMutex()); + const auto locker = qt_scoped_lock(resourceMutex()); return *resourceSearchPaths(); } #endif @@ -950,7 +950,7 @@ Q_CORE_EXPORT bool qRegisterResourceData(int version, const unsigned char *tree, { if (resourceGlobalData.isDestroyed()) return false; - QMutexLocker lock(resourceMutex()); + const auto locker = qt_scoped_lock(resourceMutex()); ResourceList *list = resourceList(); if (version >= 0x01 && version <= 0x3) { bool found = false; @@ -977,7 +977,7 @@ Q_CORE_EXPORT bool qUnregisterResourceData(int version, const unsigned char *tre if (resourceGlobalData.isDestroyed()) return false; - QMutexLocker lock(resourceMutex()); + const auto locker = qt_scoped_lock(resourceMutex()); if (version >= 0x01 && version <= 0x3) { QResourceRoot res(version, tree, name, data); ResourceList *list = resourceList(); @@ -1198,7 +1198,7 @@ QResource::registerResource(const QString &rccFilename, const QString &resourceR QDynamicFileResourceRoot *root = new QDynamicFileResourceRoot(r); if(root->registerSelf(rccFilename)) { root->ref.ref(); - QMutexLocker lock(resourceMutex()); + const auto locker = qt_scoped_lock(resourceMutex()); resourceList()->append(root); return true; } @@ -1222,7 +1222,7 @@ QResource::unregisterResource(const QString &rccFilename, const QString &resourc { QString r = qt_resource_fixResourceRoot(resourceRoot); - QMutexLocker lock(resourceMutex()); + const auto locker = qt_scoped_lock(resourceMutex()); ResourceList *list = resourceList(); for(int i = 0; i < list->size(); ++i) { QResourceRoot *res = list->at(i); @@ -1269,7 +1269,7 @@ QResource::registerResource(const uchar *rccData, const QString &resourceRoot) QDynamicBufferResourceRoot *root = new QDynamicBufferResourceRoot(r); if (root->registerSelf(rccData, -1)) { root->ref.ref(); - QMutexLocker lock(resourceMutex()); + const auto locker = qt_scoped_lock(resourceMutex()); resourceList()->append(root); return true; } @@ -1293,7 +1293,7 @@ QResource::unregisterResource(const uchar *rccData, const QString &resourceRoot) { QString r = qt_resource_fixResourceRoot(resourceRoot); - QMutexLocker lock(resourceMutex()); + const auto locker = qt_scoped_lock(resourceMutex()); ResourceList *list = resourceList(); for(int i = 0; i < list->size(); ++i) { QResourceRoot *res = list->at(i);