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

Calling addStretch followed by addItem leads to QList warning

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • None
    • 5.15
    • Widgets: GraphicsView
    • None
    • Linux/X11

    Description

      This is similar to some other bugs that have been filed: QTBUG-103775QTBUG-85909QTBUG-79223, but none are exactly the same.

      There was a change to cause QList to warn when adding items outside of the range (https://codereview.qt-project.org/registerc/qt/qtbase/+/276371), which affects a few different components.

      In this case it is QGraphicsLayout. For example in this code:

      QGraphicsLinearLayout* layout = new QGraphicsLinearLayout;
      QGraphicsWidget* widget = new QGraphicsWidget;
      widget->setLayout(layout);
      widget->addStretch();
      widget->addItem(new QGraphicsWidget);

      This will (as of Qt 5.15) print a (debug-mode) warning "QList::insert(): Index out of range", which I understand will become an assert in Qt 6.

      Is this code valid? If so, is it possible to make it not warn/assert? I am concerned that this case isn't accounted for with the QList change. (Example now attached)

      Attachments

        Issue Links

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

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              mpnolan87 Michael Nolan
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes