diff options
4 files changed, 36 insertions, 11 deletions
diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index fd3d8a92e3..f6eb4bc40e 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -1275,9 +1275,13 @@ void QQmlComponentAndAliasResolver::findAndRegisterImplicitComponents(const QtQm const QtQml::QmlObject *targetObject = qmlObjects->at(binding->value.objectIndex); QQmlCompiledData::TypeReference *tr = resolvedTypes->value(targetObject->inheritedTypeNameIndex); Q_ASSERT(tr); - QQmlType *targetType = tr->type; - if (targetType && targetType->metaObject() == &QQmlComponent::staticMetaObject) - continue; + if (QQmlType *targetType = tr->type) { + if (targetType->metaObject() == &QQmlComponent::staticMetaObject) + continue; + } else if (tr->component) { + if (tr->component->rootPropertyCache->firstCppMetaObject() == &QQmlComponent::staticMetaObject) + continue; + } QQmlPropertyData *pd = 0; if (binding->propertyNameIndex != 0) { 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() |