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

Exponential signal slot connections when traversing parents

    XMLWordPrintable

Details

    Description

      I have code which traverses its parents to check if it is nested within a particular type. Below is a simpler version which just counts the depth. The item gets moved around so its parent changes. That causes exponential behavior. Perhaps the connection is not a UniqueConnection but it should be.

      This is a regression in Qt 5.8. I bisected it to qtdeclarative/9ab8b9e4bdf313bb4304be206dd479d4d0848211 (QML: Do not register static QML dependencies on every call.).

      import QtQuick 2.4
       
      Item {
          id: root
       
          property var outOfLineObject
       
          property var calledCount: [0]
       
          Item {
              id: thirdItem
              Item {
                  id: outerItem
                  Item {
                      id: innerItem
       
                      Item {
                          id: deeperItem
       
                          property var someProp: {
                              ++root.calledCount[0]
                              var parent = deeperItem.parent
                              var depth = 1;
                              while (parent) {
                                  parent = parent.parent
                                  depth+=1;
                              }
                              return depth;
                          }
                      }
                  }
              }
          }
       
          Text {
              width: 100
              height: 100
              text: "Text" + deeperItem.someProp
          }
       
          Timer {
              running: true
              repeat: true
              interval: 1000
              onTriggered: {
                  root.calledCount[0] = 0;
                  deeperItem.parent = deeperItem.parent === null ? innerItem : null;
                  console.log("CALLED", root.calledCount[0])
              }
          }
      }
      

      Output:

      qmlscene traverse_parents.qml
      qml: CALLED 6
      qml: CALLED 12
      qml: CALLED 24
      qml: CALLED 48
      qml: CALLED 96
      qml: CALLED 192
      qml: CALLED 384
      qml: CALLED 768
      qml: CALLED 1536
      qml: CALLED 3072
      qml: CALLED 6144
      qml: CALLED 12288
      qml: CALLED 24576
      qml: CALLED 49152
      qml: CALLED 98304
      qml: CALLED 196608
      qml: CALLED 393216
      qml: CALLED 786432
      qml: CALLED 1572864
      qml: CALLED 3145728
      qml: CALLED 6291456
      qml: CALLED 12582912
      

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            ske Steve
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes