aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2017-09-12 15:13:33 +0200
committerLars Knoll <lars.knoll@qt.io>2017-09-12 19:50:13 +0000
commit98358715930739ca8de172d88c5ce6941c275ff3 (patch)
tree614a2af39d4b8fc122d3900281c6a3ca1ec8331e /src
parent78d574a909a4bcf7543fba8d921e8658dfbc0200 (diff)
Fix qml cache invalidation when changing dependent C++ registered QML singletons
When a qml file uses a qml singleton, we need to reliably detect when the singleton changes and re-generate the cache of the qml file using it. This is a scenario covered and fixed by commit 5b94de09cc738837d1539e28b3c0dccd17c18d29, with the exception that currently QML singletons registered via qmlRegisterSingleton were not added to the list of dependent singletons for a qml file. We can fix this by extending findCompositeSingletons() to also cover the singletons that do not originate from a qmldir file. [ChangeLog][Qt][Qml] Fixed bug where sometimes changes to a qml singleton would not propagate to the users or cause crashes. Task-number: QTBUG-62243 Change-Id: I16c3d9ba65fd82e898a29b946c341907751135a9 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qml/qml/qqmlimport.cpp11
-rw-r--r--src/qml/qml/qqmlmetatype.cpp12
-rw-r--r--src/qml/qml/qqmlmetatype_p.h2
3 files changed, 25 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index 0bd7317470..ccd287e1b6 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -471,6 +471,17 @@ void findCompositeSingletons(const QQmlImportNamespace &set, QList<QQmlImports::
resultList.append(ref);
}
}
+
+ if (QQmlTypeModule *module = QQmlMetaType::typeModule(import->uri, import->majversion)) {
+ module->walkCompositeSingletons([&resultList, &set](const QQmlType &singleton) {
+ QQmlImports::CompositeSingletonReference ref;
+ ref.typeName = singleton.elementName();
+ ref.prefix = set.prefix;
+ ref.majorVersion = singleton.majorVersion();
+ ref.minorVersion = singleton.minorVersion();
+ resultList.append(ref);
+ });
+ }
}
}
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index 5bbc250d5e..8f5d11a96f 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -1258,6 +1258,18 @@ QQmlType QQmlTypeModule::type(const QV4::String *name, int minor) const
return QQmlType();
}
+void QQmlTypeModule::walkCompositeSingletons(const std::function<void(const QQmlType &)> &callback) const
+{
+ QMutexLocker lock(metaTypeDataLock());
+ for (auto typeCandidates = d->typeHash.begin(), end = d->typeHash.end();
+ typeCandidates != end; ++typeCandidates) {
+ for (auto type: typeCandidates.value()) {
+ if (type->regType == QQmlType::CompositeSingletonType)
+ callback(QQmlType(type));
+ }
+ }
+}
+
QQmlTypeModuleVersion::QQmlTypeModuleVersion()
: m_module(0), m_minor(0)
{
diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h
index ac2133ba30..9a7736ffcd 100644
--- a/src/qml/qml/qqmlmetatype_p.h
+++ b/src/qml/qml/qqmlmetatype_p.h
@@ -298,6 +298,8 @@ public:
QQmlType type(const QHashedStringRef &, int) const;
QQmlType type(const QV4::String *, int) const;
+ void walkCompositeSingletons(const std::function<void(const QQmlType &)> &callback) const;
+
QQmlTypeModulePrivate *priv() { return d; }
private:
//Used by register functions and creates the QQmlTypeModule for them