From 72e0d699cec09458ca9325035d477d4899e8e47b Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 23 Oct 2020 19:07:05 +0200 Subject: 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 --- src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib/itemmodels') 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; } -- cgit v1.2.3