Fix QAbstractItemModelTester false positive
When rows are removed from a model with no columns, the test should not report a problem if indexes are invalid Fixes: QTBUG-92886 Pick-to: 6.1 6.0 5.15 Change-Id: I7a042dfdb2575f87208a00cbed13db3869807f84 Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
parent
4d838dae5a
commit
fed2c0d236
@ -721,12 +721,12 @@ void QAbstractItemModelTesterPrivate::rowsAboutToBeRemoved(const QModelIndex &pa
|
||||
Changing c;
|
||||
c.parent = parent;
|
||||
c.oldSize = model->rowCount(parent);
|
||||
if (start > 0) {
|
||||
if (start > 0 && model->columnCount(parent) > 0) {
|
||||
const QModelIndex startIndex = model->index(start - 1, 0, parent);
|
||||
MODELTESTER_VERIFY(startIndex.isValid());
|
||||
c.last = model->data(startIndex);
|
||||
}
|
||||
if (end < c.oldSize - 1) {
|
||||
if (end < c.oldSize - 1 && model->columnCount(parent) > 0) {
|
||||
const QModelIndex endIndex = model->index(end + 1, 0, parent);
|
||||
MODELTESTER_VERIFY(endIndex.isValid());
|
||||
c.next = model->data(endIndex);
|
||||
|
@ -106,13 +106,16 @@ void tst_QAbstractItemModelTester::standardItemModel()
|
||||
model.insertColumns(0, 5, model.index(1, 3));
|
||||
}
|
||||
|
||||
void tst_QAbstractItemModelTester::standardItemModelZeroColumns() // QTBUG-92220
|
||||
void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
|
||||
{
|
||||
QStandardItemModel model;
|
||||
|
||||
QAbstractItemModelTester t1(&model);
|
||||
// QTBUG-92220
|
||||
model.insertRows(0, 5);
|
||||
model.removeRows(0, 5);
|
||||
// QTBUG-92886
|
||||
model.insertRows(0, 5);
|
||||
model.removeRows(1, 2);
|
||||
}
|
||||
|
||||
void tst_QAbstractItemModelTester::testInsertThroughProxy()
|
||||
|
Loading…
Reference in New Issue
Block a user