Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.2
-
None
Description
Q_ASSERT(last < rowCount(parent)) failure. QAbstractItemModel::beginRemoveRows function is called on empty model from QAbstractItemModelReplicaImplementation::onRowsRemoved. My guess, onRowsRemoved is called before model size sync and treeFullyLazyLoaded check is buggy.
void QAbstractItemModel::beginRemoveRows(const QModelIndex &parent, int first, int last) { Q_ASSERT(first >= 0); Q_ASSERT(last >= first); Q_ASSERT(last < rowCount(parent)); // failure, beginRemoveRows called on empty model Q_D(QAbstractItemModel); d->changes.push(QAbstractItemModelPrivate::Change(parent, first, last)); emit rowsAboutToBeRemoved(parent, first, last, QPrivateSignal()); d->rowsAboutToBeRemoved(parent, first, last); } void QAbstractItemModelReplicaImplementation::onRowsRemoved(const IndexList &parent, int start, int end) { qCDebug(QT_REMOTEOBJECT_MODELS) << Q_FUNC_INFO << "start=" << start << "end=" << end << "parent=" << parent; // my guess, onRowsRemoved is called before model size sync and this check is buggy bool treeFullyLazyLoaded = true; const QModelIndex parentIndex = toQModelIndex(parent, q, &treeFullyLazyLoaded); if (!treeFullyLazyLoaded) return; // beginRemoveRows is called on empty model auto parentItem = cacheData(parentIndex); q->beginRemoveRows(parentIndex, start, end); if (parentItem) parentItem->removeChildren(start, end); q->endRemoveRows(); }