Details
-
Bug
-
Resolution: Done
-
P2: Important
-
None
-
5.5.0
-
None
-
OS: ANY
COMPILER: ANY
Description
QListView tries to access QListModeViewBase::flowPositions at incorrect index position.
This can be achieved when list view's layout mode is set up to Batched.
Then call scrollTo() method with an index as an argument which row will be equal to size of QListModeViewBase::flowPositions - 1.
There is a code to test the bug:
QListView* view = new QListView(); view->setLayoutMode(QListView::Batched); int batchSize = view->batchSize(); //view->setBatchSize(batchSize); QStandardItemModel* model = new QStandardItemModel(); for (int i = 0; i < batchSize + 10; ++i) { model->appendRow(new QStandardItem(QString::number(i))); } view->setModel(model); // this line will make assert: view->scrollTo(model->index(batchSize - 1, 0));
The problem seems to be incapsulated in the method QListModeViewBase::indexToListViewItem
In the condition at the top there is a check:
index.row() >= flowPositions.count()
But flowPositions is +1 larger than actual row count (see QListModeViewBase::perItemScrollToValue).
Therefore the condition at QListModeViewBase::indexToListViewItem should be:
index.row() >= flowPositions.count() - 1