Skip to content

Commit

Permalink
QAbstractItemModelTester: fix false positive when model has zero columns
Browse files Browse the repository at this point in the history
Regression introduced by me in commit 72e0d69

Fixes: QTBUG-92220
Change-Id: Ic7dd4eda0a1993f9763933882baf928bfc83b08b
Pick-to: 6.1 6.0 5.15
Reviewed-by: Luca Beldi <[email protected]>
Reviewed-by: Alexandru Croitor <[email protected]>
  • Loading branch information
dfaure-kdab committed Mar 30, 2021
1 parent c80f262 commit b4aac2a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/testlib/qabstractitemmodeltester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ void QAbstractItemModelTesterPrivate::parent()
// when asked for the parent of an invalid index.
MODELTESTER_VERIFY(!model->parent(QModelIndex()).isValid());

if (model->rowCount() == 0)
if (model->rowCount() == 0 || model->columnCount() == 0)
return;

// Column 0 | Column 1 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ private slots:
void stringListModel();
void treeWidgetModel();
void standardItemModel();
void standardItemModelZeroColumns();
void testInsertThroughProxy();
void moveSourceItems();
void testResetThroughProxy();
Expand Down Expand Up @@ -105,6 +106,15 @@ void tst_QAbstractItemModelTester::standardItemModel()
model.insertColumns(0, 5, model.index(1, 3));
}

void tst_QAbstractItemModelTester::standardItemModelZeroColumns() // QTBUG-92220
{
QStandardItemModel model;

QAbstractItemModelTester t1(&model);
model.insertRows(0, 5);
model.removeRows(0, 5);
}

void tst_QAbstractItemModelTester::testInsertThroughProxy()
{
DynamicTreeModel *model = new DynamicTreeModel(this);
Expand Down

0 comments on commit b4aac2a

Please sign in to comment.