diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2024-02-27 12:54:27 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2024-02-29 17:48:21 +0100 |
commit | 98ecc9adbbb0f032f4ef4341d4cdd896158d4409 (patch) | |
tree | 5515af3afed692df3309b4afa3f3a05865a759dd /src/qml/types/qqmlbind.cpp | |
parent | 27c25c8ddc1d911056ff0b49c1524bee4deaec73 (diff) |
Binding: fix restore logic
Consider a Binding affecting a property which initially has a value (not
a binding).
When restoring the initial value of a property, we did not remove any
binding that might have been installed on it by Binding. Then, when the
Binding would subsequently get enabled again, it would pick up the still
installed binding instead of the actually restored property.
From that point on, the original value would have been lost.
Fix this by clearing any existing bindings when we restore a value.
Pick-to: 6.7 6.6 6.5
Fixes: QTBUG-122707
Change-Id: Ife7c43c7e799c71257fc04bbd76ff902422bd49d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/types/qqmlbind.cpp')
-rw-r--r-- | src/qml/types/qqmlbind.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/qml/types/qqmlbind.cpp b/src/qml/types/qqmlbind.cpp index b59c4fd5a9..bc06d4ed51 100644 --- a/src/qml/types/qqmlbind.cpp +++ b/src/qml/types/qqmlbind.cpp @@ -1029,6 +1029,7 @@ void QQmlBind::eval() break; case QQmlBindEntryKind::V4Value: if (d->restoreValue) { + QQmlAnyBinding::takeFrom(entry.prop); // we don't want to have a binding active auto propPriv = QQmlPropertyPrivate::get(entry.prop); QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(propPriv->object); Q_ASSERT(vmemo); @@ -1039,6 +1040,7 @@ void QQmlBind::eval() break; case QQmlBindEntryKind::Variant: if (d->restoreValue) { + QQmlAnyBinding::takeFrom(entry.prop); // we don't want to have a binding active entry.prop.write(entry.previous.variant); entry.clearPrev(); } |