summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qresource.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io/qresource.cpp')
-rw-r--r--src/corelib/io/qresource.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index febf22639c..32639759e4 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -149,12 +149,23 @@ static QString cleanPath(const QString &_path)
Q_DECLARE_TYPEINFO(QResourceRoot, Q_MOVABLE_TYPE);
-Q_GLOBAL_STATIC_WITH_ARGS(QMutex, resourceMutex, (QMutex::Recursive))
-
typedef QList<QResourceRoot*> ResourceList;
-Q_GLOBAL_STATIC(ResourceList, resourceList)
+struct QResourceGlobalData
+{
+ QMutex resourceMutex{QMutex::Recursive};
+ ResourceList resourceList;
+ QStringList resourceSearchPaths;
+};
+Q_GLOBAL_STATIC(QResourceGlobalData, resourceGlobalData)
+
+static inline QMutex *resourceMutex()
+{ return &resourceGlobalData->resourceMutex; }
-Q_GLOBAL_STATIC(QStringList, resourceSearchPaths)
+static inline ResourceList *resourceList()
+{ return &resourceGlobalData->resourceList; }
+
+static inline QStringList *resourceSearchPaths()
+{ return &resourceGlobalData->resourceSearchPaths; }
/*!
\class QResource
@@ -870,6 +881,9 @@ Q_CORE_EXPORT bool qRegisterResourceData(int version, const unsigned char *tree,
Q_CORE_EXPORT bool qUnregisterResourceData(int version, const unsigned char *tree,
const unsigned char *name, const unsigned char *data)
{
+ if (resourceGlobalData.isDestroyed())
+ return false;
+
QMutexLocker lock(resourceMutex());
if ((version == 0x01 || version == 0x02) && resourceList()) {
QResourceRoot res(version, tree, name, data);