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

Component completion inconsistencies

XMLWordPrintable

      Given the following QML:

       

      import QtQuick
      
      Rectangle {
          objectName: "0"
      
          Item {
              objectName: "1";
              Component.onCompleted: console.log("Component.onCompleted " + objectName)
          }
          Item {
              objectName: "2";
              Component.onCompleted: console.log("Component.onCompleted " + objectName)
      
              Item {
                  objectName: "2.1";
                  Component.onCompleted: console.log("Component.onCompleted " + objectName)
              }
              Item {
                  objectName: "2.2";
                  Component.onCompleted: console.log("Component.onCompleted " + objectName)
              }
          }
          Item {
              objectName: "3";
              Component.onCompleted: console.log("Component.onCompleted " + objectName)
          }
      
          Component.onCompleted: console.log("Component.onCompleted " + objectName)
      

      The order of QQmlParserStatus::componentComplete() and Component.onCompleted is inconsistent:

      QQuickItem::componentComplete QQuickItem(0x6000039d0d20, name="3", parent=0x6000039d5420, geometry=0,0 0x0)
      QQuickItem::componentComplete QQuickItem(0x6000039c42a0, name="2.2", parent=0x6000039c4380, geometry=0,0 0x0)
      QQuickItem::componentComplete QQuickItem(0x6000039dc380, name="2.1", parent=0x6000039c4380, geometry=0,0 0x0)
      QQuickItem::componentComplete QQuickItem(0x6000039c4380, name="2", parent=0x6000039d5420, geometry=0,0 0x0)
      QQuickItem::componentComplete QQuickItem(0x6000039d57a0, name="1", parent=0x6000039d5420, geometry=0,0 0x0)
      QQuickItem::componentComplete QQuickRectangle(0x6000039d5420, name="0", parent=0x0, geometry=0,0 0x0)
      Component.onCompleted 0
      Component.onCompleted 3
      Component.onCompleted 2
      Component.onCompleted 2.2
      Component.onCompleted 2.1
      Component.onCompleted 1

      QQuickItem::componentComplete happens "inside out", with lead nodes completing before their parents, while Component.onCompleted happens "outside-in", with parents completed before their children.

      The order of completion within a single item for child items is also reversed, compared to the document order of the items.

      From what I understand, neither of these behaviors are documented or defined. It would be nice if we could make them consistent, and also follow the document order.

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

            qtqmlteam Qt Qml Team User
            vestbo Tor Arne Vestbø
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes