aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2022-09-17 13:51:05 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2022-12-15 14:03:55 +0100
commit7d5cc737db18b321f224eef168639382d3f1f4b9 (patch)
treed706a0d3d8588b83e74245ad3e92b6ba7108ce77 /tests/auto/qml/qqmlecmascript
parent07d2a80d015f0598f8f3e193ba814121085cc45a (diff)
QmlObjectCreator: play nice with grouped properties
If an object tries to set up a grouped property binding of the form complex.subprop: primitiveValue when complex is declared in a base element, and the setup of it is done in base, then we so far would get an error about complex being null. The reason for that is an optimization which only sets up bindings shortly before object creation concludes (to avoid spurious reevaluations during construction). Because setting primitive value "bindings" happens however without delay, we end up with the case of attempting to set up the value of a non-existent object. To fix this we check if there is a binding which might provide the object, evaluate it at that point, and to then re-read the outer property of the group. As a drive-by, add missing QT_{BEGIN,END}_NAMESPACE macro to qqmlanybinding_p.h. Otherwise, the namespace build (finally) fails to compile. Pick-to: 6.5 Fixes: QTBUG-108102 Change-Id: Ifdac1948100b369a49c0a5ecff75f881fd63540e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlecmascript')
-rw-r--r--tests/auto/qml/qqmlecmascript/data/groupPropertyInstantiationOrder.qml36
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp13
2 files changed, 49 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/groupPropertyInstantiationOrder.qml b/tests/auto/qml/qqmlecmascript/data/groupPropertyInstantiationOrder.qml
new file mode 100644
index 0000000000..626d1e4225
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/groupPropertyInstantiationOrder.qml
@@ -0,0 +1,36 @@
+import QtQuick 2.15
+
+Item {
+
+ width: 100
+ height: 100
+
+ component Screen01 : Rectangle {
+
+ property Text myText: text1
+
+ id: root
+
+ width: 100
+ height: 100
+
+ Text {
+ id: text1
+ anchors.centerIn: parent
+ color: "salmon"
+ font.pixelSize: 14
+ }
+ }
+
+ Screen01 {
+ id: screen1
+ property int speed : 42
+ property int final_size: 14
+
+
+ myText{
+ font.pixelSize: 50 - final_size
+ text: speed
+ }
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 862b85851f..66d9dc7324 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -94,6 +94,7 @@ private slots:
void valueTypeFunctions();
void constantsOverrideBindings();
void outerBindingOverridesInnerBinding();
+ void groupPropertyBindingOrder();
void aliasPropertyAndBinding();
void aliasPropertyReset();
void aliasPropertyToIC();
@@ -1669,6 +1670,18 @@ void tst_qqmlecmascript::outerBindingOverridesInnerBinding()
}
/*
+ Tests that group property bindings work to objects
+ of a base element
+ */
+void tst_qqmlecmascript::groupPropertyBindingOrder()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("groupPropertyInstantiationOrder.qml"));
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY2(obj, qPrintable(component.errorString()));
+}
+
+/*
Access a non-existent attached object.
Tests for a regression where this used to crash.