diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-12-04 14:24:24 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-05 10:06:08 +0100 |
commit | 32d05752e00218a40516d43069fca2bee0d9894e (patch) | |
tree | a5078b1a864aa872f0762e4369ced45768a984c9 /src/qml/qml/qqmlcompileddata.cpp | |
parent | 268f4615dcf19aad3603833af83ba28eca886aa5 (diff) |
Fix dynamic properties in QQmlPropertyMap not always being visible in QML
QQmlPropertyMap is a fully dynamic class that can add properties at any point
in time. In order for these properties to be visible inside QML, we must
disable the property cache (instead of trying to unsuccessfully re-fresh it).
What happened in this particular case is that the QQmlPropertyMap derived type
was instantiated and the VME instruction for creating it would also assign the
property cache the compiler determined. There's no way for QQmlPropertyMap
itself to access this property cache instance (stored in
output->types[id].typePropertyCache) or invalidate it, so instead don't use the
compiler's property cache when instantiating the type.
This patch also disallows the adding properties to QQmlPropertyMap when it
is used as base type for a new QML type, as we cannot provide the derived
type to the QQmlPropertyMap constructor - this is only possible in C++.
Task-number: QTBUG-35233
Change-Id: I7fa9e4a2224ccfdd7ccb3fd9f73919ecd46058a8
Reviewed-by: Alberto Mardegan <mardy@users.sourceforge.net>
Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlcompileddata.cpp')
-rw-r--r-- | src/qml/qml/qqmlcompileddata.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlcompileddata.cpp b/src/qml/qml/qqmlcompileddata.cpp index 9fcef176ad..76bf24fe6b 100644 --- a/src/qml/qml/qqmlcompileddata.cpp +++ b/src/qml/qml/qqmlcompileddata.cpp @@ -45,6 +45,7 @@ #include "qqmlcomponent_p.h" #include "qqmlcontext.h" #include "qqmlcontext_p.h" +#include "qqmlpropertymap.h" #ifdef QML_THREADED_VME_INTERPRETER #include "qqmlvme_p.h" #endif @@ -173,6 +174,27 @@ QQmlPropertyCache *QQmlCompiledData::TypeReference::createPropertyCache(QQmlEngi } } +template <typename T> +bool qtTypeInherits(const QMetaObject *mo) { + while (mo) { + if (mo == &T::staticMetaObject) + return true; + mo = mo->superClass(); + } + return false; +} + +void QQmlCompiledData::TypeReference::doDynamicTypeCheck() +{ + const QMetaObject *mo = 0; + if (typePropertyCache) + mo = typePropertyCache->firstCppMetaObject(); + else if (type) + mo = type->metaObject(); + else + mo = component->rootPropertyCache->firstCppMetaObject(); + isFullyDynamicType = qtTypeInherits<QQmlPropertyMap>(mo); +} void QQmlCompiledData::dumpInstructions() { |