aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/compiler/qqmltypecompiler.cpp23
-rw-r--r--src/qml/compiler/qqmltypecompiler_p.h2
-rw-r--r--tests/auto/qml/qqmllanguage/data/autoComponentCreationInGroupProperties.qml6
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.h4
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp13
5 files changed, 37 insertions, 11 deletions
diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp
index a1085b1388..2165f3d651 100644
--- a/src/qml/compiler/qqmltypecompiler.cpp
+++ b/src/qml/compiler/qqmltypecompiler.cpp
@@ -1040,12 +1040,8 @@ QQmlComponentAndAliasResolver::QQmlComponentAndAliasResolver(QQmlTypeCompiler *t
{
}
-void QQmlComponentAndAliasResolver::findAndRegisterImplicitComponents(const QtQml::QmlObject *obj, int objectIndex)
+void QQmlComponentAndAliasResolver::findAndRegisterImplicitComponents(const QtQml::QmlObject *obj, QQmlPropertyCache *propertyCache)
{
- QQmlPropertyCache *propertyCache = propertyCaches.value(objectIndex);
- if (!propertyCache)
- return;
-
PropertyResolver propertyResolver(propertyCache);
QQmlPropertyData *defaultProperty = obj->indexOfDefaultProperty != -1 ? propertyCache->parent()->defaultProperty() : propertyCache->defaultProperty();
@@ -1124,13 +1120,20 @@ bool QQmlComponentAndAliasResolver::resolve()
const int objCountWithoutSynthesizedComponents = qmlObjects->count();
for (int i = 0; i < objCountWithoutSynthesizedComponents; ++i) {
const QtQml::QmlObject *obj = qmlObjects->at(i);
- if (obj->inheritedTypeNameIndex == 0)
+ QQmlPropertyCache *cache = propertyCaches.value(i);
+ if (obj->inheritedTypeNameIndex == 0 && !cache)
continue;
- QQmlCompiledData::TypeReference *tref = resolvedTypes->value(obj->inheritedTypeNameIndex);
- Q_ASSERT(tref);
- if (!tref->type || tref->type->metaObject() != &QQmlComponent::staticMetaObject) {
- findAndRegisterImplicitComponents(obj, i);
+ bool isExplicitComponent = false;
+
+ if (obj->inheritedTypeNameIndex) {
+ QQmlCompiledData::TypeReference *tref = resolvedTypes->value(obj->inheritedTypeNameIndex);
+ Q_ASSERT(tref);
+ if (tref->type && tref->type->metaObject() == &QQmlComponent::staticMetaObject)
+ isExplicitComponent = true;
+ }
+ if (!isExplicitComponent) {
+ findAndRegisterImplicitComponents(obj, cache);
continue;
}
diff --git a/src/qml/compiler/qqmltypecompiler_p.h b/src/qml/compiler/qqmltypecompiler_p.h
index 71ae77ac5c..6c4532da5e 100644
--- a/src/qml/compiler/qqmltypecompiler_p.h
+++ b/src/qml/compiler/qqmltypecompiler_p.h
@@ -183,7 +183,7 @@ public:
bool resolve();
protected:
- void findAndRegisterImplicitComponents(const QtQml::QmlObject *obj, int objectIndex);
+ void findAndRegisterImplicitComponents(const QtQml::QmlObject *obj, QQmlPropertyCache *propertyCache);
bool collectIdsAndAliases(int objectIndex);
bool resolveAliases();
diff --git a/tests/auto/qml/qqmllanguage/data/autoComponentCreationInGroupProperties.qml b/tests/auto/qml/qqmllanguage/data/autoComponentCreationInGroupProperties.qml
new file mode 100644
index 0000000000..6dae861e62
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/autoComponentCreationInGroupProperties.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+MyTypeObject {
+ selfGroupProperty {
+ componentProperty : MyTypeObject { realProperty: 9 }
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h
index 27ad340256..5086180da1 100644
--- a/tests/auto/qml/qqmllanguage/testtypes.h
+++ b/tests/auto/qml/qqmllanguage/testtypes.h
@@ -256,6 +256,8 @@ class MyTypeObject : public QObject
Q_PROPERTY(MyGroupedObject *grouped READ grouped CONSTANT)
Q_PROPERTY(MyGroupedObject *nullGrouped READ nullGrouped CONSTANT)
+ Q_PROPERTY(MyTypeObject *selfGroupProperty READ selfGroupProperty)
+
public:
MyTypeObject()
: objectPropertyValue(0), componentPropertyValue(0) {}
@@ -550,6 +552,8 @@ public:
MyGroupedObject *nullGrouped() { return 0; }
+ MyTypeObject *selfGroupProperty() { return this; }
+
void doAction() { emit action(); }
signals:
void action();
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 826bd124b7..07644bef16 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -117,6 +117,7 @@ private slots:
void dynamicSignalsAndSlots();
void simpleBindings();
void autoComponentCreation();
+ void autoComponentCreationInGroupProperty();
void propertyValueSource();
void attachedProperties();
void dynamicObjects();
@@ -1351,6 +1352,18 @@ void tst_qqmllanguage::autoComponentCreation()
QCOMPARE(child->realProperty(), qreal(9));
}
+void tst_qqmllanguage::autoComponentCreationInGroupProperty()
+{
+ QQmlComponent component(&engine, testFileUrl("autoComponentCreationInGroupProperties.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::propertyValueSource()
{
{