diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-05-03 10:31:05 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-05-10 23:00:40 +0200 |
commit | 9da03da2e3fec3cfc9c4e6bfcf7f433845723d65 (patch) | |
tree | 086a148ec8128c086a125b3fc842d6032c517c74 /tests | |
parent | 1b5463ccfbe3fde74adf8e0651662cad1979c216 (diff) |
Apply constant binding removal optimization to QProperty bindings
This applies the logic from 7cb6dce1f3e140ea68d6b05281950f212fc99d38 to
non-QQmlAbstractBinding bindings, too.
The logic to detect whether a binding has no dependencies has consider
the QPropertyBindingPrivate's dependency observer count.
In addition, change the existing detection logic to remove properties
without a context, too. The original logic probably wanted to guard
against accessing binding->context()->unresolvedNames when context was
nullptr; however, the check should have tested "context ->
unresolvedNames", not "context and unresolvedNames". And after the
refactoring which introduced hasUnresolvedNames() as a function, the
context check became completely superfluous.
Fixes: QTBUG-92996
Change-Id: Ia3bc39e184f431210b3bb2d38154acf820525e98
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/data/removeQPropertyBindingsWithNoDependencies.qml | 8 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/removeQPropertyBindingsWithNoDependencies.qml b/tests/auto/qml/qqmlecmascript/data/removeQPropertyBindingsWithNoDependencies.qml new file mode 100644 index 0000000000..680e7f4c4e --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/removeQPropertyBindingsWithNoDependencies.qml @@ -0,0 +1,8 @@ +import Qt.test 1 + +ClassWithQProperty { + id: root + function f() {return 42} + + value: f() +} diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 89e0246623..6f2e241cc1 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -9074,6 +9074,14 @@ void tst_qqmlecmascript::removeBindingsWithNoDependencies() QVERIFY(!proxy->subBindings()); } + { + QQmlComponent component(&engine, testFileUrl("removeQPropertyBindingsWithNoDependencies.qml")); + QScopedPointer<QObject> root(component.create()); + QVERIFY2(root, qPrintable(component.errorString())); + auto classWithQProperty = qobject_cast<ClassWithQProperty *>(root.get()); + QVERIFY(!classWithQProperty->bindableValue().hasBinding()); + QCOMPARE(classWithQProperty->value.value(), 42); + } } void tst_qqmlecmascript::preserveBindingWithUnresolvedNames() |