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

assertion failure when using children() to get objectlist

    XMLWordPrintable

Details

    Description

      Trying to get a list of children using children() but results into an assert
      `
      ASSERT: "!isEmpty()" in file ../../../../Qt5.4.1/5.4/gcc/include/QtCore/qlist.h, line 293
      `
      I've narrowed it down to following example

      main.qml
      import QtQuick 2.4
      
      Rectangle {
          width: 100
          height: 100
      
          property int xval: 0
      
          Behavior on xval {
              SmoothedAnimation {
                  //id: a
                  duration: 800
              }
          }
      
          /*Rectangle {
              width: 50
              height: 50
      
              Rectangle {
                  width: 10
                  height: 10
              }
          }*/
      }
      

      and loading it as

      main.cpp
      QQuickView view;
      view.setSource(QStringLiteral("qrc:/main.qml"));
      view.show();
      
      QQuickItem *item = view.rootObject();
      qDebug() << item->children().first()->children().first();
      

      This should actually ouput the SmoothedAnimation object but the children list is actually 0. Now if you specify an id to SmoothedAnimation, the object is found. Is there any compulsion that an id is required ?
      I tried the similar scenario with Rectangle (commented code) and it works as expected.

      Attachments

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

        Activity

          People

            qtqmlteam Qt Qml Team User
            ashishd ashish
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes