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

ids are not properly resolved when using cachegen

XMLWordPrintable

    • Linux/X11

      Given the following code

      MyObject.qml
      import QtQuick
      
      QtObject {
          property var foo: "bla"
      }
      
      Main.qml
      import QtQuick
      import QtQuick.Controls
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          Control {
              anchors.fill: parent
      
              MyObject {
                  id: my
                  foo: foo
              }
              property Item myprop: Item {
                  id: foo
              }
              contentItem: Text {
                  text: String(my.foo)
              }
          }
      }
      

      According to Qt documentation, the line "foo: foo" should set the property "foo" to the object with "id: foo". The expected behavior is then that the window should display something like "QQuickItem(0x...)".

      However when cachegen is enabled, the line "foo: foo" binds the property "foo" to itself, creating a binding loop. And the window displays "bla".

      When "NO_CACHEGEN" is set in qt_add_qml_module(), the expected behavior occurs.

      This seems to happen only when the object with the "foo: foo" binding and the object with "id: foo' are separated by a property assignation.

      Binding loop
      MyItem {
        id: my
        foo: foo // Binding loop, they are "separated" by the contentItem
      }
      
      contentItem: Text {
        text: String(my.foo)
        Item {
          id: foo
        }
      }
      
      No binding loop
      contentItem: Text {
        text: String(my.foo)
        Item {
          id: foo
        }
        MyItem {
          id: my
          foo: foo //No binding loop, they are both inside the contenItem
        }
      }
      

        For Gerrit Dashboard: QTBUG-140041
        # Subject Branch Project Status CR V

            ulherman Ulf Hermann
            bterrier Benjamin Terrier
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There is 1 open Gerrit change