summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2018-06-25 16:26:46 +0200
committerDavid Faure <david.faure@kdab.com>2018-06-27 10:12:01 +0000
commit4af292fe5158c2d19e8ab1351c71c3940c7f1032 (patch)
tree7f955de029e97d391b2bb283bbe9645f7a80d66f /src
parent27ea5a65dd3fdabdad1569f5330f90248cdca4f5 (diff)
QAbstractItemModelTester: don't call match(QModelIndex(), ...)
The documentation for match() indicates that the index has to be valid since it determines which column to search in (in addition to "from which row"). So call match with a valid index, if the model isn't empty. Change-Id: I5f3754cf14d053bf04d207cefe7dcc938e0f4a5a Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/testlib/qabstractitemmodeltester.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/testlib/qabstractitemmodeltester.cpp b/src/testlib/qabstractitemmodeltester.cpp
index 04fa99bc4d..fc6f696ecd 100644
--- a/src/testlib/qabstractitemmodeltester.cpp
+++ b/src/testlib/qabstractitemmodeltester.cpp
@@ -322,9 +322,10 @@ void QAbstractItemModelTesterPrivate::nonDestructiveBasicTest()
Qt::ItemFlags flags = model->flags(QModelIndex());
MODELTESTER_VERIFY(flags == Qt::ItemIsDropEnabled || flags == 0);
model->hasChildren(QModelIndex());
- model->hasIndex(0, 0);
+ const bool hasRow = model->hasIndex(0, 0);
QVariant cache;
- model->match(QModelIndex(), -1, cache);
+ if (hasRow)
+ model->match(model->index(0, 0), -1, cache);
model->mimeTypes();
MODELTESTER_VERIFY(!model->parent(QModelIndex()).isValid());
MODELTESTER_VERIFY(model->rowCount() >= 0);