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

Binding doesn't seem to be released on changed 'when' property

    XMLWordPrintable

Details

    • 82f2ee802 (dev), 35de689c6 (6.5)

    Description

      Changing the 'target' of a binding by pressing the button in

      import QtQuick
      import QtQuick.Controls.Material
      
      Window {
          id: win
          width: 640
          height: 480
          visible: true
          title: "Wohooooo"
      
          Component {
              id: sourceComponent1
      
              Item {
                  property string moo
              }
          }
      
          Component {
              id: sourceComponent2
      
              Item {}
          }
      
          Loader {
              id: loader
              sourceComponent: sourceComponent1
          }
      
          Button {
              text: "Click me"
              onClicked: () => {
                  loader.sourceComponent = sourceComponent2
              }
          }
      
          Binding {
              target: loader.item
              when: loader.item && loader.item.hasOwnProperty("moo")
              property: "moo"
              value: "42 is the answer"
          }
      }
      

      runs into

      qrc:/untitled/main.qml:41:5: QML Binding: Property 'moo' does not exist on QQuickItem*.
      

      while I'd expect the binding to be deactivated due to the missing moo property

      Attachments

        For Gerrit Dashboard: QTBUG-112860
        # Subject Branch Project Status CR V

        Activity

          People

            fabiankosmale Fabian Kosmale
            cajus Cajus Pollmeier
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes