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

Setters for QProperty-based properties should not register observers on those properties

XMLWordPrintable

    • Icon: Epic Epic
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 6.5, 6.6.0 FF
    • Core: Other
    • None
    • Do not register property setters as dependencies of the properties they set

      This was found when investigating a binding loop on QObject::setObjectName, but there probably are more occurrences of the same pattern. The pattern is:

          if (d->extraData->objectName != name) {
              d->extraData->objectName.setValueBypassingBindings(name);
              d->extraData->objectName.notify(); // also emits a signal
          }
      

      By reading objectName in the first line, we register an observer on the QProperty. This is not what we want. Rather, if we need the value, we should read it bypassing the binding:

          if (d->extraData->objectName.valueBypassingBindings() != name) {
              d->extraData->objectName.setValueBypassingBindings(name);
              d->extraData->objectName.notify(); // also emits a signal
          }
      

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

            cnn Qt Core & Network
            ulherman Ulf Hermann
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes