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

Effects applied on a Item using the layer.effect property mess with its parent children property

    XMLWordPrintable

Details

    Description

      When setting an effect on an item using the Item::layer.effect property, the children property of item's parent gets polluted with new children.

      Test code:

      Item{
      
          Rectangle {
              width: 100
              height: 100
              color: "green"
      
              layer {
                  effect: ColorOverlay {
                      color: "red"
                  }
                  enabled: true
              }
          }
      
          Rectangle {
              width: 100
              height: 100
              color: "green"
      
              layer {
                  effect: ColorOverlay {
                      color: "blue"
                  }
                  enabled: true
              }
          }
      
          Component.onCompleted: {
      
              print("Children count : " + children.length)
      
              for(var i = 0 ; i < children.length; i++) print("|- " ,children[i])
          }
      }
      
      

      When printing the item contents we see that there is in fact 6 children in it :

      Children count : 6
      |-  QQuickRectangle(0xcce188)
      |-  QQuickShaderEffectSource(0xccacb8)
      |-  ColorOverlay_QMLTYPE_1(0xccad18)
      |-  QQuickRectangle(0xd059c8)
      |-  QQuickShaderEffectSource(0xd099a8)
      |-  ColorOverlay_QMLTYPE_1(0xcc34b8)
      

      It is not expected that the parent tree gets modified when applying an effect on an item.

      This leads to issues in layouts which has been partially fixed (see https://bugreports.qt-project.org/browse/QTBUG-31269
      ) with a change in QtQuick Positionner but I would expect it to be fixed at the source of the issue in QtQuick Item since there is still issues when some code relies on the children property.

      Related topic in the forum : http://qt-project.org/forums/viewthread/40815/

      Attachments

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

        Activity

          People

            sletta Gunnar Sletta
            x-krys Christopher Courtois
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes