Skip to content

Commit

Permalink
QAbstractItemModelTester: don't call match(QModelIndex(), ...)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dfaure-kdab committed Jun 27, 2018
1 parent 27ea5a6 commit 4af292f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/testlib/qabstractitemmodeltester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4af292f

Please sign in to comment.