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

Repeater items prematurely destructed in asynchronous Loader

    XMLWordPrintable

Details

    • 6dc0ba50bab2fa72978a7b5ee63dae9d66e8ad40

    Description

      Asynchronous Loader that has a source component of Row with a Repeater of 10 Text items. The delegates 1-9 get destructed as soon as they are constructed. Only the last one survives.

      // main.cpp
      #include <QGuiApplication>
      #include <QQuickView>
      
      int main(int argc, char* argv[])
      {
          QGuiApplication app(argc, argv);
          QQuickView view;
          view.setSource(QUrl::fromLocalFile("main.qml"));
          view.show();
          return app.exec();
      }
      
      // main.qml
      import QtQuick 2.1
      
      Loader {
          width: 300
          height: 200
      
          asynchronous: true
      
          sourceComponent: Row {
              Repeater {
                  Text {
                      text: index
                      Component.onCompleted: console.log("Component.onCompleted:", index)
                      Component.onDestruction: console.log("Component.onDestruction:", index)
                  }
      
                  model: ListModel { id: model }
                  onCountChanged: console.log("count:", count)
              }
      
              Component.onCompleted: {
                  for (var i = 0; i < 10; ++i)
                      model.append({"foo": "bar"})
              }
          }
      }
      

      PS. The problem does not occur with qmlscene.

      Attachments

        Issue Links

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

          Activity

            People

              jolind Jorgen Lind
              jpnurmi J-P Nurmi
              Votes:
              3 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes