aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-09-30 16:20:19 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-09-30 17:11:52 +0200
commit224f053eba157fb908f08909d8e2015d76b08295 (patch)
tree18c8207e3fe03b9dfa5754736be7d3fc51ece468 /src/qml/qml
parentcf51a723ffbddc5338628b99fa4a5b5b4d17295c (diff)
Use a QQmlRefPointer for QQmlScriptData::typeNameCache
The cache can get overwritten. We want the reference to the old one to be dropped then. Fixes: QTBUG-78865 Change-Id: I8ebba4ae242c3bf8ae4db5cffc65b26bab265b8a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmlscriptblob.cpp4
-rw-r--r--src/qml/qml/qqmlscriptdata.cpp6
-rw-r--r--src/qml/qml/qqmlscriptdata_p.h2
3 files changed, 4 insertions, 8 deletions
diff --git a/src/qml/qml/qqmlscriptblob.cpp b/src/qml/qml/qqmlscriptblob.cpp
index 69b26894a8..6ac30d3ab5 100644
--- a/src/qml/qml/qqmlscriptblob.cpp
+++ b/src/qml/qml/qqmlscriptblob.cpp
@@ -177,7 +177,7 @@ void QQmlScriptBlob::done()
}
if (!m_isModule) {
- m_scriptData->typeNameCache = new QQmlTypeNameCache(m_importCache);
+ m_scriptData->typeNameCache.adopt(new QQmlTypeNameCache(m_importCache));
QSet<QString> ns;
@@ -195,7 +195,7 @@ void QQmlScriptBlob::done()
m_scriptData->typeNameCache->add(script.qualifier, scriptIndex, script.nameSpace);
}
- m_importCache.populateCache(m_scriptData->typeNameCache);
+ m_importCache.populateCache(m_scriptData->typeNameCache.data());
}
m_scripts.clear();
}
diff --git a/src/qml/qml/qqmlscriptdata.cpp b/src/qml/qml/qqmlscriptdata.cpp
index 0725f40d2a..ae268ca904 100644
--- a/src/qml/qml/qqmlscriptdata.cpp
+++ b/src/qml/qml/qqmlscriptdata.cpp
@@ -156,11 +156,7 @@ QV4::ReturnedValue QQmlScriptData::scriptValueForContext(QQmlContextData *parent
void QQmlScriptData::clear()
{
- if (typeNameCache) {
- typeNameCache->release();
- typeNameCache = nullptr;
- }
-
+ typeNameCache = nullptr;
scripts.clear();
// An addref() was made when the QQmlCleanup was added to the engine.
diff --git a/src/qml/qml/qqmlscriptdata_p.h b/src/qml/qml/qqmlscriptdata_p.h
index 273ba3691f..80b65b699c 100644
--- a/src/qml/qml/qqmlscriptdata_p.h
+++ b/src/qml/qml/qqmlscriptdata_p.h
@@ -82,7 +82,7 @@ private:
public:
QUrl url;
QString urlString;
- QQmlTypeNameCache *typeNameCache;
+ QQmlRefPointer<QQmlTypeNameCache> typeNameCache;
QVector<QQmlRefPointer<QQmlScriptBlob>> scripts;
QV4::ReturnedValue scriptValueForContext(QQmlContextData *parentCtxt);