Fix access incorrect index in QListView with batch layout
The size of flowPositions is larger by one than the number of rows in the model so the last correct row number is flowPositions.count()-2, not flowPositions.count()-1. Change-Id: Idf8bbd155151d553947d5d299dd01ffaff0c95fa Task-number: QTBUG-47694 Reviewed-by: Alexander Volkov <a.volkov@rusbitech.ru> Reviewed-by: David Faure <david.faure@kdab.com>bb10
parent
117b3e1b8f
commit
0243863382
|
|
@ -2348,7 +2348,7 @@ QListViewItem QListModeViewBase::indexToListViewItem(const QModelIndex &index) c
|
|||
{
|
||||
if (flowPositions.isEmpty()
|
||||
|| segmentPositions.isEmpty()
|
||||
|| index.row() >= flowPositions.count())
|
||||
|| index.row() >= flowPositions.count() - 1)
|
||||
return QListViewItem();
|
||||
|
||||
const int segment = qBinarySearch<int>(segmentStartRows, index.row(),
|
||||
|
|
|
|||
|
|
@ -150,6 +150,7 @@ private slots:
|
|||
void horizontalScrollingByVerticalWheelEvents();
|
||||
void taskQTBUG_7232_AllowUserToControlSingleStep();
|
||||
void taskQTBUG_51086_skippingIndexesInSelectedIndexes();
|
||||
void taskQTBUG_47694_indexOutOfBoundBatchLayout();
|
||||
};
|
||||
|
||||
// Testing get/set functions
|
||||
|
|
@ -2486,5 +2487,18 @@ void tst_QListView::taskQTBUG_51086_skippingIndexesInSelectedIndexes()
|
|||
QVERIFY(!indexes.contains(data.index(8, 0)));
|
||||
}
|
||||
|
||||
void tst_QListView::taskQTBUG_47694_indexOutOfBoundBatchLayout()
|
||||
{
|
||||
QListView view;
|
||||
view.setLayoutMode(QListView::Batched);
|
||||
int batchSize = view.batchSize();
|
||||
|
||||
QStandardItemModel model(batchSize + 1, 1);
|
||||
|
||||
view.setModel(&model);
|
||||
|
||||
view.scrollTo(model.index(batchSize - 1, 0));
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QListView)
|
||||
#include "tst_qlistview.moc"
|
||||
|
|
|
|||
Loading…
Reference in New Issue