diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-03-25 16:24:03 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-27 20:39:59 +0100 |
commit | cfd5a1fb4ed1c51c3dadab0c63820c625992069d (patch) | |
tree | fbd56339d1cb510c5f849e862ad222603ad94eab /tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | |
parent | 57f4d8b490b994b124278b2c7c656319dfe0382f (diff) |
Fix instantiation of QML list models with custom object properties
When doing something like
property Item blah: Item { ... }
in a list model, we would erroneously pass "blah" to the custom parser of the
list model, which is wrong as the binding to blah is on an existing property
(not custom). For regular properties there's a code path in place to avoid
passing this to the custom parser, but for sub-object bindings we'd
unconditionally register it with the custom parser. This patch corrects that
and also adds a unit test to verify that we don't pass any bindings to existing
properties to the custom parser.
Task-number: QTBUG-37795
Change-Id: I1a3091fb5fad4be08b577cf74a85f24c3ab62ef4
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp')
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index e5c86e744d..619c7719f6 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -229,6 +229,7 @@ private slots: void customParserBindingScopes(); void customParserEvaluateEnum(); + void customParserProperties(); void preservePropertyCacheOnGroupObjects(); void propertyCacheInSync(); @@ -3598,6 +3599,20 @@ void tst_qqmllanguage::customParserEvaluateEnum() QVERIFY(!o.isNull()); } +void tst_qqmllanguage::customParserProperties() +{ + QQmlComponent component(&engine, testFile("customParserProperties.qml")); + VERIFY_ERRORS(0); + QScopedPointer<QObject> o(component.create()); + QVERIFY(!o.isNull()); + SimpleObjectWithCustomParser *testObject = qobject_cast<SimpleObjectWithCustomParser*>(o.data()); + QVERIFY(testObject); + QCOMPARE(testObject->customBindingsCount(), 0); + QCOMPARE(testObject->intProperty(), 42); + QCOMPARE(testObject->property("qmlString").toString(), QStringLiteral("Hello")); + QVERIFY(!testObject->property("someObject").isNull()); +} + void tst_qqmllanguage::preservePropertyCacheOnGroupObjects() { QQmlComponent component(&engine, testFile("preservePropertyCacheOnGroupObjects.qml")); |