summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Beldi <v.ronin@yahoo.it>2021-04-23 15:35:29 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-04-26 14:19:13 +0000
commitf2e156c13780677214cbb943fa2bcc9a8c6bd986 (patch)
tree254f14b170f022f792dd40788834f6f5057bdcf4
parenta36a738a931eb9e204e33d71951642131cf40b82 (diff)
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>
-rw-r--r--src/testlib/qabstractitemmodeltester.cpp2
-rw-r--r--tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp4
2 files changed, 5 insertions, 1 deletions
diff --git a/src/testlib/qabstractitemmodeltester.cpp b/src/testlib/qabstractitemmodeltester.cpp
index 4acbf42e00..e6daf7bed4 100644
--- a/src/testlib/qabstractitemmodeltester.cpp
+++ b/src/testlib/qabstractitemmodeltester.cpp
@@ -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);
diff --git a/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
index 8e5b20757d..928008a379 100644
--- a/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+++ b/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
@@ -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()