QResource: port from QMutexLocker to qt_scoped_lock
Change-Id: I483e4765ef83d13e81bb830c9f48421410c5718b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
94a3f3a037
commit
730893c123
@ -42,7 +42,7 @@
|
|||||||
#include "qresource_p.h"
|
#include "qresource_p.h"
|
||||||
#include "qresource_iterator_p.h"
|
#include "qresource_iterator_p.h"
|
||||||
#include "qset.h"
|
#include "qset.h"
|
||||||
#include "qmutex.h"
|
#include <private/qlocking_p.h>
|
||||||
#include "qdebug.h"
|
#include "qdebug.h"
|
||||||
#include "qlocale.h"
|
#include "qlocale.h"
|
||||||
#include "qglobal.h"
|
#include "qglobal.h"
|
||||||
@ -203,8 +203,8 @@ struct QResourceGlobalData
|
|||||||
};
|
};
|
||||||
Q_GLOBAL_STATIC(QResourceGlobalData, resourceGlobalData)
|
Q_GLOBAL_STATIC(QResourceGlobalData, resourceGlobalData)
|
||||||
|
|
||||||
static inline QRecursiveMutex *resourceMutex()
|
static inline QRecursiveMutex &resourceMutex()
|
||||||
{ return &resourceGlobalData->resourceMutex; }
|
{ return resourceGlobalData->resourceMutex; }
|
||||||
|
|
||||||
static inline ResourceList *resourceList()
|
static inline ResourceList *resourceList()
|
||||||
{ return &resourceGlobalData->resourceList; }
|
{ return &resourceGlobalData->resourceList; }
|
||||||
@ -337,7 +337,7 @@ bool
|
|||||||
QResourcePrivate::load(const QString &file)
|
QResourcePrivate::load(const QString &file)
|
||||||
{
|
{
|
||||||
related.clear();
|
related.clear();
|
||||||
QMutexLocker lock(resourceMutex());
|
const auto locker = qt_scoped_lock(resourceMutex());
|
||||||
const ResourceList *list = resourceList();
|
const ResourceList *list = resourceList();
|
||||||
QString cleaned = cleanPath(file);
|
QString cleaned = cleanPath(file);
|
||||||
for(int i = 0; i < list->size(); ++i) {
|
for(int i = 0; i < list->size(); ++i) {
|
||||||
@ -392,7 +392,7 @@ QResourcePrivate::ensureInitialized() const
|
|||||||
if(path.startsWith(QLatin1Char('/'))) {
|
if(path.startsWith(QLatin1Char('/'))) {
|
||||||
that->load(path.toString());
|
that->load(path.toString());
|
||||||
} else {
|
} else {
|
||||||
QMutexLocker lock(resourceMutex());
|
const auto locker = qt_scoped_lock(resourceMutex());
|
||||||
QStringList searchPaths = *resourceSearchPaths();
|
QStringList searchPaths = *resourceSearchPaths();
|
||||||
searchPaths << QLatin1String("");
|
searchPaths << QLatin1String("");
|
||||||
for(int i = 0; i < searchPaths.size(); ++i) {
|
for(int i = 0; i < searchPaths.size(); ++i) {
|
||||||
@ -688,7 +688,7 @@ QResource::addSearchPath(const QString &path)
|
|||||||
path.toLocal8Bit().data());
|
path.toLocal8Bit().data());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QMutexLocker lock(resourceMutex());
|
const auto locker = qt_scoped_lock(resourceMutex());
|
||||||
resourceSearchPaths()->prepend(path);
|
resourceSearchPaths()->prepend(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -706,7 +706,7 @@ QResource::addSearchPath(const QString &path)
|
|||||||
QStringList
|
QStringList
|
||||||
QResource::searchPaths()
|
QResource::searchPaths()
|
||||||
{
|
{
|
||||||
QMutexLocker lock(resourceMutex());
|
const auto locker = qt_scoped_lock(resourceMutex());
|
||||||
return *resourceSearchPaths();
|
return *resourceSearchPaths();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -950,7 +950,7 @@ Q_CORE_EXPORT bool qRegisterResourceData(int version, const unsigned char *tree,
|
|||||||
{
|
{
|
||||||
if (resourceGlobalData.isDestroyed())
|
if (resourceGlobalData.isDestroyed())
|
||||||
return false;
|
return false;
|
||||||
QMutexLocker lock(resourceMutex());
|
const auto locker = qt_scoped_lock(resourceMutex());
|
||||||
ResourceList *list = resourceList();
|
ResourceList *list = resourceList();
|
||||||
if (version >= 0x01 && version <= 0x3) {
|
if (version >= 0x01 && version <= 0x3) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
@ -977,7 +977,7 @@ Q_CORE_EXPORT bool qUnregisterResourceData(int version, const unsigned char *tre
|
|||||||
if (resourceGlobalData.isDestroyed())
|
if (resourceGlobalData.isDestroyed())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QMutexLocker lock(resourceMutex());
|
const auto locker = qt_scoped_lock(resourceMutex());
|
||||||
if (version >= 0x01 && version <= 0x3) {
|
if (version >= 0x01 && version <= 0x3) {
|
||||||
QResourceRoot res(version, tree, name, data);
|
QResourceRoot res(version, tree, name, data);
|
||||||
ResourceList *list = resourceList();
|
ResourceList *list = resourceList();
|
||||||
@ -1198,7 +1198,7 @@ QResource::registerResource(const QString &rccFilename, const QString &resourceR
|
|||||||
QDynamicFileResourceRoot *root = new QDynamicFileResourceRoot(r);
|
QDynamicFileResourceRoot *root = new QDynamicFileResourceRoot(r);
|
||||||
if(root->registerSelf(rccFilename)) {
|
if(root->registerSelf(rccFilename)) {
|
||||||
root->ref.ref();
|
root->ref.ref();
|
||||||
QMutexLocker lock(resourceMutex());
|
const auto locker = qt_scoped_lock(resourceMutex());
|
||||||
resourceList()->append(root);
|
resourceList()->append(root);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1222,7 +1222,7 @@ QResource::unregisterResource(const QString &rccFilename, const QString &resourc
|
|||||||
{
|
{
|
||||||
QString r = qt_resource_fixResourceRoot(resourceRoot);
|
QString r = qt_resource_fixResourceRoot(resourceRoot);
|
||||||
|
|
||||||
QMutexLocker lock(resourceMutex());
|
const auto locker = qt_scoped_lock(resourceMutex());
|
||||||
ResourceList *list = resourceList();
|
ResourceList *list = resourceList();
|
||||||
for(int i = 0; i < list->size(); ++i) {
|
for(int i = 0; i < list->size(); ++i) {
|
||||||
QResourceRoot *res = list->at(i);
|
QResourceRoot *res = list->at(i);
|
||||||
@ -1269,7 +1269,7 @@ QResource::registerResource(const uchar *rccData, const QString &resourceRoot)
|
|||||||
QDynamicBufferResourceRoot *root = new QDynamicBufferResourceRoot(r);
|
QDynamicBufferResourceRoot *root = new QDynamicBufferResourceRoot(r);
|
||||||
if (root->registerSelf(rccData, -1)) {
|
if (root->registerSelf(rccData, -1)) {
|
||||||
root->ref.ref();
|
root->ref.ref();
|
||||||
QMutexLocker lock(resourceMutex());
|
const auto locker = qt_scoped_lock(resourceMutex());
|
||||||
resourceList()->append(root);
|
resourceList()->append(root);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1293,7 +1293,7 @@ QResource::unregisterResource(const uchar *rccData, const QString &resourceRoot)
|
|||||||
{
|
{
|
||||||
QString r = qt_resource_fixResourceRoot(resourceRoot);
|
QString r = qt_resource_fixResourceRoot(resourceRoot);
|
||||||
|
|
||||||
QMutexLocker lock(resourceMutex());
|
const auto locker = qt_scoped_lock(resourceMutex());
|
||||||
ResourceList *list = resourceList();
|
ResourceList *list = resourceList();
|
||||||
for(int i = 0; i < list->size(); ++i) {
|
for(int i = 0; i < list->size(); ++i) {
|
||||||
QResourceRoot *res = list->at(i);
|
QResourceRoot *res = list->at(i);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user