diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-03-05 10:21:52 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-05 15:01:07 +0100 |
commit | 247f6a34d161f10c4f6d5d516b8bfb7043ca78a2 (patch) | |
tree | 4d7c89e3b4f33279a3565d5afdb925dc21b58ba0 /tests | |
parent | c8889fbb5561d75a7a383b86daa89c1b264c6f6e (diff) |
[new compiler] Fix auto component creation with composite types
A binding like this
property Component foo: SomeComposite {}
should not do an implicit component insertion if SomeComposite is actually
a component. The property assignment is compatible and can proceed normally.
Fixes tst_qquickcanvasitem, but added a separate unit test for this case.
Change-Id: I7221eebd38dba3f2a82b59341739b9b67211e352
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests')
3 files changed, 29 insertions, 8 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/MyCompositeComponent.qml b/tests/auto/qml/qqmllanguage/data/MyCompositeComponent.qml new file mode 100644 index 0000000000..474dd8952c --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/MyCompositeComponent.qml @@ -0,0 +1,5 @@ +import Test 1.0 +import QtQml 2.0 +Component { + MyTypeObject { realProperty: 9 } +} diff --git a/tests/auto/qml/qqmllanguage/data/autoComponentCreation.2.qml b/tests/auto/qml/qqmllanguage/data/autoComponentCreation.2.qml new file mode 100644 index 0000000000..7539154970 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/autoComponentCreation.2.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyTypeObject { + componentProperty : MyCompositeComponent {} +} diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 07644bef16..3a52d586ea 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -1342,14 +1342,26 @@ void tst_qqmllanguage::simpleBindings() void tst_qqmllanguage::autoComponentCreation() { - QQmlComponent component(&engine, testFileUrl("autoComponentCreation.qml")); - VERIFY_ERRORS(0); - MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); - QVERIFY(object != 0); - QVERIFY(object->componentProperty() != 0); - MyTypeObject *child = qobject_cast<MyTypeObject *>(object->componentProperty()->create()); - QVERIFY(child != 0); - QCOMPARE(child->realProperty(), qreal(9)); + { + QQmlComponent component(&engine, testFileUrl("autoComponentCreation.qml")); + VERIFY_ERRORS(0); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + QVERIFY(object->componentProperty() != 0); + MyTypeObject *child = qobject_cast<MyTypeObject *>(object->componentProperty()->create()); + QVERIFY(child != 0); + QCOMPARE(child->realProperty(), qreal(9)); + } + { + QQmlComponent component(&engine, testFileUrl("autoComponentCreation.2.qml")); + VERIFY_ERRORS(0); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + QVERIFY(object->componentProperty() != 0); + MyTypeObject *child = qobject_cast<MyTypeObject *>(object->componentProperty()->create()); + QVERIFY(child != 0); + QCOMPARE(child->realProperty(), qreal(9)); + } } void tst_qqmllanguage::autoComponentCreationInGroupProperty() |