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

Context properties are not consistently available for child items created in stateless JS library

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.0.2, 5.1.0
    • None
    • Ubuntu 13.04, 64 bit

    Description

      An item created using the following function in a stateless JS library does not have access to properties that are available in the context of theParent:

      function createObjectFromFile(fileName, theParent) {
      var component = Qt.createComponent(fileName);
      return component.createObject(theParent);
      }

      See attachment where an item is created in a JS library file four times in slightly different ways. Cases A, B, C work but case D fails with "MyText.qml:4: ReferenceError: root is not defined"

      I could understand a logic where an item created in a stateless library does not have a context, but in this case, the parent of the created item does have access to the properties in the context, and I would expect cases C and D to give the same results.

      Attachments

        1. contextTest.qml
          1 kB
          Tim Peeters
        2. contextTest.qmlproject
          0.4 kB
          Tim Peeters
        3. CreateState.js
          0.3 kB
          Tim Peeters
        4. CreateStateless.js
          0.3 kB
          Tim Peeters
        5. MyText.qml
          0.1 kB
          Tim Peeters
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            shausman Simon Hausmann
            tpeeters Tim Peeters
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes