aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-09-08 17:21:10 +0200
committerUlf Hermann <ulf.hermann@qt.io>2022-09-13 16:54:55 +0200
commitd5e7e3970d7155d93b81e8cd145e6ee51f13ce72 (patch)
treee432286af53832f46ddbc871767c242064cc6eff
parented27061e8fbf71d8bbf2756b167805c4942b6a08 (diff)
Qml: Don't crash on bad grouped properties
Fixes: QTBUG-106457 Change-Id: Id36b54fd3ed413c0ac49e33e5ea87984d5220aef Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit e061c934d5a6d93493ba2be7b61efdd055d1e164) Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--src/qml/qml/qqmlpropertycachecreator.cpp4
-rw-r--r--tests/auto/qml/qqmllanguage/data/badGroupedProperty.qml10
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp12
3 files changed, 25 insertions, 1 deletions
diff --git a/src/qml/qml/qqmlpropertycachecreator.cpp b/src/qml/qml/qqmlpropertycachecreator.cpp
index 5e5a3aa840..fe68337eb3 100644
--- a/src/qml/qml/qqmlpropertycachecreator.cpp
+++ b/src/qml/qml/qqmlpropertycachecreator.cpp
@@ -115,8 +115,10 @@ bool QQmlBindingInstantiationContext::resolveInstantiatingProperty()
return true;
}
+ if (!referencingObjectPropertyCache)
+ return false;
+
Q_ASSERT(referencingObjectIndex >= 0);
- Q_ASSERT(referencingObjectPropertyCache);
Q_ASSERT(instantiatingBinding->propertyNameIndex != 0);
bool notInRevision = false;
diff --git a/tests/auto/qml/qqmllanguage/data/badGroupedProperty.qml b/tests/auto/qml/qqmllanguage/data/badGroupedProperty.qml
new file mode 100644
index 0000000000..1b8ba61725
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/badGroupedProperty.qml
@@ -0,0 +1,10 @@
+import QtQml
+
+QtObject {
+ id: testItem
+ property rect rect
+ onComplete {
+ rect.x: 2
+ rect.width: 22
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 4a7a0b4085..e5586d27c9 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -398,6 +398,7 @@ private slots:
void uncreatableAttached();
void bindableOnly();
+ void badGroupedProperty();
private:
QQmlEngine engine;
@@ -6921,6 +6922,17 @@ void tst_qqmllanguage::bindableOnly()
QCOMPARE(o->objectName(), QStringLiteral("score"));
}
+void tst_qqmllanguage::badGroupedProperty()
+{
+ QQmlEngine engine;
+ const QUrl url = testFileUrl("badGroupedProperty.qml");
+ QQmlComponent c(&engine, url);
+ QVERIFY(c.isError());
+ QCOMPARE(c.errorString(),
+ QStringLiteral("%1:6 Cannot assign to non-existent property \"onComplete\"\n")
+ .arg(url.toString()));
+}
+
QTEST_MAIN(tst_qqmllanguage)
#include "tst_qqmllanguage.moc"