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

QAbstractItemView::setModel() basic sanity checking of the model (Q_ASSERT_X)

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Out of scope
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 4.5.3
    • Widgets: Itemviews
    • None

      Can you, please, add d->model->rowCount() == 0 || checking to these asserts?
      When model is empty, these asserts check nothing, but call model::index() with "invalid" args.
      It's legal but always suspicious, and should be avoided, I think.
       
          // These asserts do basic sanity checking of the model
          Q_ASSERT_X(d->model->rowCount() == 0 || d->model->index(0,0) == d->model->index(0,0),
                     "QAbstractItemView::setModel",
                     "A model should return the exact same index "
                     "(including its internal id/pointer) when asked for it twice in a row.");
          Q_ASSERT_X(d->model->rowCount() == 0 || d->model->index(0,0).parent() == QModelIndex(),
                     "QAbstractItemView::setModel",
                     "The parent of a top level index should be invalid");

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

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            ilyan Ilya Nikulshin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes