aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp17
-rw-r--r--tests/auto/qml/qqmllanguage/data/GroupPropertyBase.qml6
-rw-r--r--tests/auto/qml/qqmllanguage/data/GroupType.qml4
-rw-r--r--tests/auto/qml/qqmllanguage/data/preservePropertyCacheOnGroupObjects.qml6
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp21
5 files changed, 48 insertions, 6 deletions
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index ac438b2b7c..150401a358 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -796,12 +796,6 @@ bool QQmlObjectCreator::setPropertyBinding(QQmlPropertyData *property, const QV4
groupObject = valueType;
valueTypeProperty = property;
} else {
- groupObjectPropertyCache = enginePrivate->propertyCacheForType(property->propType);
- if (!groupObjectPropertyCache) {
- recordError(binding->location, tr("Invalid grouped property access"));
- return false;
- }
-
void *argv[1] = { &groupObject };
QMetaObject::metacall(_qobject, QMetaObject::ReadProperty, property->coreIndex, argv);
if (!groupObject) {
@@ -809,6 +803,16 @@ bool QQmlObjectCreator::setPropertyBinding(QQmlPropertyData *property, const QV4
return false;
}
+ if (QQmlData *groupDeclarativeData = QQmlData::get(groupObject))
+ groupObjectPropertyCache = groupDeclarativeData->propertyCache;
+ if (!groupObjectPropertyCache)
+ groupObjectPropertyCache = enginePrivate->propertyCacheForType(property->propType);
+ if (!groupObjectPropertyCache) {
+ recordError(binding->location, tr("Invalid grouped property access"));
+ return false;
+ }
+
+
bindingTarget = groupObject;
}
@@ -1284,6 +1288,7 @@ bool QQmlObjectCreator::populateInstance(int index, QObject *instance, QQmlRefPo
vmeMetaObject = new QQmlVMEMetaObject(_qobject, _propertyCache, reinterpret_cast<const QQmlVMEMetaData*>(data.constData()));
if (_ddata->propertyCache)
_ddata->propertyCache->release();
+ Q_ASSERT(installPropertyCache);
scopeObjectProtector = _ddata->jsWrapper.value();
} else {
vmeMetaObject = QQmlVMEMetaObject::get(_qobject);
diff --git a/tests/auto/qml/qqmllanguage/data/GroupPropertyBase.qml b/tests/auto/qml/qqmllanguage/data/GroupPropertyBase.qml
new file mode 100644
index 0000000000..a2534359be
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/GroupPropertyBase.qml
@@ -0,0 +1,6 @@
+import QtQml 2.0
+QtObject {
+ property GroupType subObject: GroupType {
+ property int newProperty: 100;
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/data/GroupType.qml b/tests/auto/qml/qqmllanguage/data/GroupType.qml
new file mode 100644
index 0000000000..d1219deea6
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/GroupType.qml
@@ -0,0 +1,4 @@
+import QtQml 2.0
+QtObject {
+ property int value: 10
+}
diff --git a/tests/auto/qml/qqmllanguage/data/preservePropertyCacheOnGroupObjects.qml b/tests/auto/qml/qqmllanguage/data/preservePropertyCacheOnGroupObjects.qml
new file mode 100644
index 0000000000..031cf3b1f8
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/preservePropertyCacheOnGroupObjects.qml
@@ -0,0 +1,6 @@
+import QtQml 2.0
+GroupPropertyBase {
+ subObject {
+ value: 42
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 3a52d586ea..c7a26c72db 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -218,6 +218,8 @@ private slots:
void customParserBindingScopes();
void customParserEvaluateEnum();
+ void preservePropertyCacheOnGroupObjects();
+
private:
QQmlEngine engine;
QStringList defaultImportPathList;
@@ -3581,6 +3583,25 @@ void tst_qqmllanguage::customParserEvaluateEnum()
QVERIFY(!o.isNull());
}
+void tst_qqmllanguage::preservePropertyCacheOnGroupObjects()
+{
+ QQmlComponent component(&engine, testFile("preservePropertyCacheOnGroupObjects.qml"));
+ VERIFY_ERRORS(0);
+ QScopedPointer<QObject> o(component.create());
+ QVERIFY(!o.isNull());
+ QObject *subObject = qvariant_cast<QObject*>(o->property("subObject"));
+ QVERIFY(subObject);
+ QCOMPARE(subObject->property("value").toInt(), 42);
+
+ QQmlData *ddata = QQmlData::get(subObject);
+ QVERIFY(ddata);
+ QQmlPropertyCache *subCache = ddata->propertyCache;
+ QVERIFY(subCache);
+ QQmlPropertyData *pd = subCache->property(QStringLiteral("newProperty"), /*object*/0, /*context*/0);
+ QVERIFY(pd);
+ QCOMPARE(pd->propType, qMetaTypeId<int>());
+}
+
QTEST_MAIN(tst_qqmllanguage)
#include "tst_qqmllanguage.moc"