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

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

    XMLWordPrintable

Details

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

    Description

      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");

      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
              ilyan Ilya Nikulshin
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes