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

Should be able to delay binding evaluation for dynamically created objects

    XMLWordPrintable

Details

    • aa40f956bab22678b62f630af97f51f9e8fab9f8, ed742d3c46eca7584b6fcb20c2de941852613fb2

    Description

      At the moment, bindings for dynamically created objects are evaluated immediately. This produces binding errors ("cannot assign [undefined] to X", etc.) if the created object has properties with bindings, as the property values have not yet been assigned.

      A possible solution is to provide a two-step method for object creation. That is, in addition to Component::createObject(), have e.g. allocateObject() and finalizeObject() (which basically call beginCreate() and completeCreate() in QDeclarativeComponent) so you can do:

          component = Qt.createComponent("Sprite.qml");
          sprite = component.allocateObject(appWindow);
      
          if (sprite != null) {
              sprite.x = 100;
              sprite.y = 100;
              sprite.specialProperty = someObject
              component.finalizeObject()
          }
      

      This way the bindings are not evaluated until finalizeObject() is called, thus avoiding the errors.

      Attachments

        Issue Links

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

          Activity

            People

              chham Christopher Ham (closed Nokia identity) (Inactive)
              bealam Bea Lam (closed Nokia identity) (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes