summaryrefslogtreecommitdiffstats
path: root/src/corelib/itemmodels
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2020-10-23 19:07:05 +0200
committerDavid Faure <david.faure@kdab.com>2020-10-27 02:55:10 +0100
commit72e0d699cec09458ca9325035d477d4899e8e47b (patch)
tree77225cea6d416aff158f9dc1e91b39e349b73f0c /src/corelib/itemmodels
parentfeda3e7673137c3f6a9f3561276b6d21447fd881 (diff)
QAbstractItemModelTester: don't rely on hasChildren()
Dynamic models which use fetchMore to asynchronously fill subdirs (like KDirModel) return true in hasChildren() for dirs that are expected to have children (so that the "+" shows in the treeview) but do not actually have children readily available. They will be inserted later on once the async listing job is done (as a result of fetchMore triggering that job). So QAbstractItemModelTester should use rowCount instead, to find out if there are children present. This detected a bug in QConcatenateTablesProxyModel: it returned a non-zero rowCount for its items, while it's flat. Change-Id: Idcdc86159f1fc79ed5297075dfcf30c09896287a Pick-to: 5.15 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/corelib/itemmodels')
-rw-r--r--src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp b/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp
index 05baa7eed2..09deee4429 100644
--- a/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp
+++ b/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp
@@ -313,8 +313,8 @@ QModelIndex QConcatenateTablesProxyModel::parent(const QModelIndex &index) const
int QConcatenateTablesProxyModel::rowCount(const QModelIndex &parent) const
{
Q_D(const QConcatenateTablesProxyModel);
- Q_ASSERT(checkIndex(parent, QAbstractItemModel::CheckIndexOption::ParentIsInvalid)); // flat model
- Q_UNUSED(parent);
+ if (parent.isValid())
+ return 0; // flat model
return d->m_rowCount;
}