diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-07-03 17:23:04 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-09-21 15:20:17 +0200 |
commit | 5a1f13e1fcdfeb2611e4dad756da83303c1f6a2e (patch) | |
tree | 6c28c0fcd74aa1717808af364379bb2614035a32 /tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | |
parent | 47313e5181e87fd904e6de41c75dfc844ec3f278 (diff) |
Handle QProperty inside bindings
If we have a binding containing QProperties, and the binding target is
an old style binding, still we have to trigger an update if any of the
captured properties changes. We cannot reuse the
QQmlJavaScriptExpressionGuards as those depend on Qt's signals, and a
QProperty is not associated with a change signal in the general case.
Therefore, we introduce a new list of QPropertyChangeHandler, which when
triggered cause a reevaluation of the binding.
As an optimization, we skip the whole capturing process for
QQmlPropertyBinding, as that one already takes care of updating itself.
Reverts 845bbb99a41a3e4f05c2b3d05d6db748c825dca0 (because skipping the
capture is only possible when _both_ the bindee and the property in the
binding are QProperty based.)
Change-Id: Iafed2a41dcd708bcc33912ce810d803949379c63
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index c37d2b0990..ef2eb5ad03 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -383,6 +383,7 @@ private slots: void hugeStack(); void bindingOnQProperty(); void bindingOnQPropertyContextProperty(); + void bindingContainingQProperty(); void urlConstruction(); void urlPropertyInvalid(); void urlPropertySet(); @@ -9189,6 +9190,17 @@ void tst_qqmlecmascript::bindingOnQPropertyContextProperty() // QCOMPARE(classWithQProperty->value.value(), 2); } +void tst_qqmlecmascript::bindingContainingQProperty() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("bindingContainingQProperty.qml")); + QVERIFY2(component.isReady(), qPrintable(component.errorString())); + QScopedPointer<QObject> test(component.create()); + QVERIFY(!test.isNull()); + test->setProperty("value", 42.0); + QCOMPARE(test->property("expected"), 42.0); +} + void tst_qqmlecmascript::urlConstruction() { QQmlEngine qmlengine; |