aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/compiler/qqmltypecompiler.cpp2
-rw-r--r--tests/auto/qml/qqmllanguage/data/MyLazyDeferredSubObject.qml6
-rw-r--r--tests/auto/qml/qqmllanguage/data/lazyDeferredSubObject.qml5
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.cpp2
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.h20
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp16
6 files changed, 50 insertions, 1 deletions
diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp
index e17ab354cf..cd7d8ca049 100644
--- a/src/qml/compiler/qqmltypecompiler.cpp
+++ b/src/qml/compiler/qqmltypecompiler.cpp
@@ -1251,7 +1251,7 @@ bool QQmlDeferredAndCustomParserBindingScanner::scanObject(int objectIndex)
_seenObjectWithId |= seenSubObjectWithId;
}
- if (!seenSubObjectWithId
+ if (!seenSubObjectWithId && binding->type != QV4::CompiledData::Binding::Type_GroupProperty
&& !deferredPropertyNames.isEmpty() && deferredPropertyNames.contains(name)) {
binding->flags |= QV4::CompiledData::Binding::IsDeferredBinding;
diff --git a/tests/auto/qml/qqmllanguage/data/MyLazyDeferredSubObject.qml b/tests/auto/qml/qqmllanguage/data/MyLazyDeferredSubObject.qml
new file mode 100644
index 0000000000..f311f6b602
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/MyLazyDeferredSubObject.qml
@@ -0,0 +1,6 @@
+import QtQml 2.0
+import Test 1.0
+LazyDeferredSubObject {
+ subObject: QtObject { objectName: 'default' }
+ objectName: subObject.objectName
+}
diff --git a/tests/auto/qml/qqmllanguage/data/lazyDeferredSubObject.qml b/tests/auto/qml/qqmllanguage/data/lazyDeferredSubObject.qml
new file mode 100644
index 0000000000..2465a18320
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/lazyDeferredSubObject.qml
@@ -0,0 +1,5 @@
+import QtQml 2.0
+import Test 1.0
+MyLazyDeferredSubObject {
+ subObject.objectName: 'custom'
+}
diff --git a/tests/auto/qml/qqmllanguage/testtypes.cpp b/tests/auto/qml/qqmllanguage/testtypes.cpp
index bdcdaa8137..72e06d26aa 100644
--- a/tests/auto/qml/qqmllanguage/testtypes.cpp
+++ b/tests/auto/qml/qqmllanguage/testtypes.cpp
@@ -103,6 +103,8 @@ void registerTypes()
qmlRegisterSingletonType<MyTypeObjectSingleton>("Test", 1, 0, "MyTypeObjectSingleton", myTypeObjectSingleton);
qmlRegisterType<MyArrayBufferTestClass>("Test", 1, 0, "MyArrayBufferTestClass");
+
+ qmlRegisterType<LazyDeferredSubObject>("Test", 1, 0, "LazyDeferredSubObject");
}
QVariant myCustomVariantTypeConverter(const QString &data)
diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h
index 7d7a8ac6d3..b0e677feb8 100644
--- a/tests/auto/qml/qqmllanguage/testtypes.h
+++ b/tests/auto/qml/qqmllanguage/testtypes.h
@@ -1331,6 +1331,26 @@ private:
QObject *obj;
};
+class LazyDeferredSubObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QObject *subObject READ subObject WRITE setSubObject NOTIFY subObjectChanged FINAL)
+ Q_CLASSINFO("DeferredPropertyNames", "subObject");
+public:
+ LazyDeferredSubObject()
+ : obj(0)
+ {}
+
+ QObject *subObject() const { if (!obj) qmlExecuteDeferred(const_cast<LazyDeferredSubObject *>(this)); return obj; }
+ void setSubObject(QObject *o) { if (obj == o) return; obj = o; emit subObjectChanged(); }
+
+signals:
+ void subObjectChanged();
+
+private:
+ QObject *obj;
+};
+
void registerTypes();
#endif // TESTTYPES_H
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 39f5082c70..8b84ee878f 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -247,6 +247,7 @@ private slots:
void propertyCacheInSync();
void rootObjectInCreationNotForSubObjects();
+ void lazyDeferredSubObject();
void noChildEvents();
@@ -4242,6 +4243,21 @@ void tst_qqmllanguage::rootObjectInCreationNotForSubObjects()
QVERIFY(!ddata->rootObjectInCreation);
}
+// QTBUG-63036
+void tst_qqmllanguage::lazyDeferredSubObject()
+{
+ QQmlComponent component(&engine, testFile("lazyDeferredSubObject.qml"));
+ VERIFY_ERRORS(0);
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(!object.isNull());
+
+ QObject *subObject = qvariant_cast<QObject *>(object->property("subObject"));
+ QVERIFY(subObject);
+
+ QCOMPARE(object->objectName(), QStringLiteral("custom"));
+ QCOMPARE(subObject->objectName(), QStringLiteral("custom"));
+}
+
void tst_qqmllanguage::noChildEvents()
{
QQmlComponent component(&engine);