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

Binding QML Type does not warn on qt.qml.binding.removal

    XMLWordPrintable

Details

    • macOS
    • d522746afa394960bef225ba08080d8364b69a7e (qt/qtdeclarative/5.15)

    Description

      Regarding BindingSilentBreak:

      If you assign a value to a property that has a binding, qt.qml.binding.removal.debug=true will print a warning.

      However if you are using Binding QML type, the same is not true - the Binding silently stops working without warning.

      See attached very simple demo. Press each button to break the binding with an assignment. One binding using the most optimal binding expression and warns when broken. The second using the Binding type which doesn't.

      Binding type is not "explicitly" broken, since it still exists. However, its "power" is lost when the target property is assigned - it seems not to monitor this fact and so does not warn.

      -----------
      Regarding BindingSilentBreak-updated:

      The section of the Binding documentation contains the following example:

      // produces warning: "Unable to assign [undefined] to double value"

      value: if (mouse.pressed) mouse.mouseX

      ... which of course is an incomplete statement in itself and does not contain an explicit "else" clause and would produce this warning like any good compiler/interpreter. This isn't the warning I was discussing.

      I have done some further investigation and cooked up some changes in my example. The Binding element will continue to apply its changes to the target property if its source property is updated.

      The text "overwrite me!!" will be restored when the animation enabling checkbox is unchecked - but only if the button that breaks the original binding has not been pressed.

      If the 2nd button is pressed now, you see the binding break warning message correctly. However, enabling the animation (which enables the Binding object) is started and stopped, the value "New Assigned Value" is NOT restored to the property. Is this a bug? Should the Binding object restore the property binding AND the value if no binding previously existed? What if the original binding were removed while the Binding object was active? What would it restore in that case when the when goes to false? It seems that if you break the original binding while the Binding object is active, it isn't actually broken and is restored as if it were never broken when the when property goes false.

      Attachments

        Issue Links

          Activity

            People

              ulherman Ulf Hermann
              tero.pelkonen Tero Pelkonen
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: