Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-71769

QML Binding element should revert property value upon destruction

    XMLWordPrintable

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

       

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            anszom Andrzej Szombierski
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes