Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.11.0
-
None
Description
The Binding element can "undo" its applied property value when the "when" property is set to false. It would be consistent to have it also undo its effect when the Binding is destroyed.
If such behaviour would introduce regressions, then this "reverting" action could be configurable with a property on the Binding.
Minimal sample below:
// code placeholder import QtQuick 2.0 QtObject { id: top property var compo: Component { Binding { target: top property: "hello" value: "there" Component.onCompleted: print('binding was created') Component.onDestruction: print('binding was destroyed') } } property string hello: "world" onHelloChanged: print('now hello is', hello) Component.onCompleted: { print('initial value:', hello) var sub = compo.createObject(null) sub.destroy() } property var t: Timer { running: true interval: 100 onTriggered: { print('final value', hello) Qt.quit() } } }
Actual output:
qml: initial value: world qml: now hello is there qml: binding was created qml: binding was destroyed qml: final value there
Expected output:
qml: initial value: world qml: now hello is there qml: binding was created qml: binding was destroyed qml: now hello is world qml: final value world