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

Repeater: itemAt returns nullptr when count says it should be valid

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 5.1.1, 5.7
    • None

    Description

      The count property of the Repeater item is supposed to hold the number of items in the Repeater, but that is not true while the items are being created and may be whilst being deleted. See QTBUG-33474. I have attached a test case that will crash when CRASH_ENABLED is set to 1. Essentially I have registered a custom type, and I am using a QML Repeater to add a number of the children to it.

      The code for the Repeater::count is:

      int QQuickRepeater::count() const

      { Q_D(const QQuickRepeater); if (d->model) return d->model->count(); return 0; }

      the code for itemAt is

      QQuickItem *QQuickRepeater::itemAt(int index) const

      { Q_D(const QQuickRepeater); if (index >= 0 && index < d->deletables.count()) return d->deletables[index]; return 0; }

      Somehow the model is out of step with the delegate list. It may be better for count to return the delegate list's count.

      Attachments

        1. main.cpp
          0.4 kB
        2. main.qml
          0.6 kB
        3. qml.qrc
          0.1 kB
        4. QTestPaintedItem.cpp
          3 kB
        5. QTestPaintedItem.h
          4 kB
        6. RepeaterTestCase.pro
          0.6 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            w00t Robin Burchell
            petermj Peter Myerscough-Jackopson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes