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

QML Binding: order of 'value' and 'when' properties ought to be defined

    XMLWordPrintable

Details

    Description

      Given something like:

      Binding { value: some_obj.val(); when: some_obj != null }

      One would expect that the 'when' property takes priority, and prevents the 'value' prop from evaluating. In reality, it doesn't, which leads to runtime errors.

      It isn't always possible to rewrite the value expression in such a way that works as desired. For instance, in the above, I want to keep a cached version of some_obj.val, even if some_obj isn't around anymore. This essentially makes it impossible to use Binding for this case.

      Workaround until this is fixed (works, but rather ugly):

      property var intermediate: some_obj ? some_obj.val() : undefined;
      property var final
      onIntermediateChanged: { if (intermediate) { final = intermediate; } }

      Attachments

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

        Activity

          People

            shausman Simon Hausmann
            w00t Robin Burchell
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes