Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-93878

QAbstractItemModelReplica onRowsRemoved assert failure

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.15.2
    • Fix Version/s: None
    • Component/s: Remote Objects
    • Labels:
      None
    • Platform/s:
      Windows

      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();
      }
      

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            bstottle Brett Stottlemyer
            Reporter:
            moneyiac Mike
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes