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

Items created by Loader never destroyed when used from QtTest

    XMLWordPrintable

    Details

    • Commits:
      b4d23e61ed19c770caf6b993a8ab0e4474d3f417

      Description

      Following test fails when run with QtTest. If you try similar case as "stand-alone" (e.g. with qmlscene) it works ok. Loader calls deleteLater() for the items, but the DeferredDelete event never reaches the items.

      If you comment the verify lines out you can see that the item count keeps increasing, and you can see the "item destroyed" messages in sequence at the end (apparently they get deleted when the scene is deleted).

      This is a blocker issue for some of our auto tests.

      import QtQuick 2.0
      import QtTest 1.0
      
      Item {
          property int itemCount: 0
      
          Loader { id: loader }
      
          Component {
              id: item
              Item {
                  Component.onCompleted: { console.log("item created"); itemCount++ }
                  Component.onDestruction: { console.log("item destroyed"); itemCount-- }
              }
          }
      
          resources: TestCase {
              name: "URL"
      
              function test_loader() {
                  for (var i = 0; i < 5; i++) {
                      loader.sourceComponent = item
                      wait(100)
                      console.log("itemCount: " + itemCount)
                      verify(itemCount == 1)
                      loader.sourceComponent = null
                      wait(100)
                      console.log("itemCount: " + itemCount)
                      verify(itemCount == 0)
                  }
              }
          }
      }
      

        Attachments

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

          Activity

            People

            Assignee:
            charles Charles Yin (closed Nokia identity) (Inactive)
            Reporter:
            skananoj Sami Kananoja
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes