summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qresource.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-02-17 20:10:34 +0100
committerLiang Qi <liang.qi@qt.io>2017-02-17 20:10:34 +0100
commitbc4cd465dd5df82e13f3c7709166ee11289d219f (patch)
treed6323aaed6383e589fbefb6057648c22bb187c76 /src/corelib/io/qresource.cpp
parent43daefb0962794b2df256cae1098e889b9b36f12 (diff)
parent07745d7bfbf6c8d83e0243150d8ce934675dea87 (diff)
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts: qmake/Makefile.unix Change-Id: Ia18e391198222eef34ffa2df6f683e052058d032
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 febf22639c4..32639759e43 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);