Fix QAbstractItemModelTester false positive

When inserting rows to a branch with no columns
the tester should not complain about indexes being invalid

Change-Id: I466f4e5140b10f6dcf65a71f109c2d3be7336507
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit fcea8e7aa8a65de9e80136c2d603478831b246d0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Luca Beldi 2021-04-23 15:35:29 +01:00 committed by Qt Cherry-pick Bot
parent a36a738a93
commit f2e156c137
2 changed files with 5 additions and 1 deletions

View File

@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
// Common error test #2, make sure that a second level index has a parent
// that is the first level index.
if (model->rowCount(topIndex) > 0) {
if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
QModelIndex childIndex = model->index(0, 0, topIndex);
MODELTESTER_VERIFY(childIndex.isValid());
MODELTESTER_COMPARE(model->parent(childIndex), topIndex);

View File

@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
// QTBUG-92886
model.insertRows(0, 5);
model.removeRows(1, 2);
const QModelIndex parentIndex = model.index(0, 0);
model.insertRows(0, 5, parentIndex);
model.removeRows(1, 2, parentIndex);
}
void tst_QAbstractItemModelTester::testInsertThroughProxy()