aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-09-30 11:55:31 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2021-10-05 21:29:41 +0200
commit5ff83606a1c1365b95cd12ef9d45bc4e4eb13ecd (patch)
tree38dff573e85a5def338b99583a45f18f48e8f952 /tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
parent87b80813d2b944479a589e2308f0846eb0e205f3 (diff)
QQmlObjectCreator: Correctly remove overwritten bindings
For QProperty bindings, we would not explicitly remove bindings that were added and later overwritten. For "complex" bindings, that would cause some unnecessary binding evaluation during object creation. Worse, in the case of a literal binding overwriting a complex binding, we would acutally end up with the complex binding still being there, because the literal binding would result in an immediate write of the value, whereas the binding was only installed at a later point. We fix this by removing the binding from the list of to-be-installed bindings when it gets overwritten. We also now take the IsPropertyObserver flag into consideration when checking whether existing bindings should be removed: IsPropertyObserver is basically the same as IsSignalHandlerExpression, but for QProperty bindings instead of "old-style" bindings. Pick-to: 6.2 Fixes: QTBUG-96668 Change-Id: I2ef00d5b62af4f6fcc71960c38e1f0568b3b9c40 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp')
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 83d7a5ee03..25c0166fa0 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -312,6 +312,7 @@ private slots:
void replaceBinding();
void bindingBoundFunctions();
void qpropertyAndQtBinding();
+ void qpropertyBindingReplacement();
void deleteRootObjectInCreation();
void onDestruction();
void onDestructionViaGC();
@@ -7615,6 +7616,15 @@ void tst_qqmlecmascript::qpropertyAndQtBinding()
QCOMPARE(root->complex.value(), 150);
}
+void tst_qqmlecmascript::qpropertyBindingReplacement()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("qpropertyBindingReplacement.qml"));
+ QScopedPointer<QObject> root(c.create());
+ QVERIFY(root);
+ QCOMPARE(root->objectName(), u"overwritten"_qs);
+}
+
void tst_qqmlecmascript::deleteRootObjectInCreation()
{
QQmlEngine engine;