diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-03-11 13:12:38 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-11 18:31:21 +0100 |
commit | af7ba8a6194b83fe7380b8d4ae027e2f04e21f17 (patch) | |
tree | 2d8eb6e7af9c34405659dc87c9aa6a150ceaa9cb /tests/auto/qml | |
parent | 95444c589763e16fb1c2cf1e1bc892fa5cc41a3a (diff) |
Fix incorrectly initialized property cache on group objects
When initializing bindings on group objects, we would accidentally set the
property cache for the property type instead of preserving a possibly earlier
initialized cache on the ddata of the QObject.
Task-number: QTBUG-37390
Change-Id: I4d6a4ce6b3382f378f9a9ddfe11924860a15979d
Reviewed-by: Sérgio Martins <sergio.martins@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests/auto/qml')
4 files changed, 37 insertions, 0 deletions
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" |