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

No binding overwrite, but binding overwritten

    XMLWordPrintable

Details

    Description

      In code create static binding: "property bool flag1: cfg_flag1",
      and also create dynamic binding via createObject.
      I expect that either get warning "Overwriting binding on" or
      after destroying dynamic binding the old one would work.
      But old binding cleary not working after creating new binding
      and destroying it. And with QT_LOGGING_RULES="qt.qml.binding.removal.info=true"
      I didn't see any warning about overriding binding.

      import QtQuick 2.0
      import QtQuick.Controls 2.15
      
      Rectangle {
          id: rect
          width: 100
          height: 100
          color: "red"
      
          property bool flag1: {
              console.log("set flag1 to", cfg_flag1);
              return cfg_flag1;
          }
          property bool cfg_flag1: true
      
          Text {
              anchors.centerIn: parent
              text: "flag1: " + flag1.toString() + ", cfg_flag1 " + cfg_flag1.toString()
          }
      
          Timer {
              id: timer
              interval: 1000
              repeat: false
              onTriggered: {
                  console.log("timer trigger");
                  cfg_flag1 = false;
              }
          }
      
          Button {
              anchors.top: parent.top
              text: "button 1"
              onClicked: {
                  console.log("button 1 clicked");
                  let temp = cmpBinding.createObject(rect, {
                      "target": rect,
                      "property": "flag1",
                      "value": true,
                      "restoreMode": Binding.RestoreBinding,
                  });
                  temp.Component.onDestruction.connect(function() { console.log("destroyed"); });
                  temp.destroy();
                  console.log("end of clicked");
                  timer.start();
              }
          }
      
          Button {
              anchors.bottom: parent.bottom
              text: "button 2"
              onClicked: {
                  console.log("button 2 clicked");
                  cfg_flag1 = true;
                  cfg_flag1 = false;
              }
          }
      
      
          Component {
              id: cmpBinding
      
              Binding {
              }
      
          }
      }
      

      Attachments

        Issue Links

          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
              davemilter davemilter
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes