https://mail.kde.org/pipermail/distributions/2026-May/001692.html https://bugs.kde.org/show_bug.cgi?id=520252 https://qt-project.atlassian.net/browse/QTBUG-146869 --- a/src/qmlmodels/qqmltableinstancemodel.cpp +++ b/src/qmlmodels/qqmltableinstancemodel.cpp @@ -166,24 +166,19 @@ Q_ASSERT(m_delegate); - QQmlDelegateModelItem *modelItem = resolveModelItem(index, QModelIndex()); - if (!modelItem) - return nullptr; + QModelIndex modelIndex; + if (const QAbstractItemModel *aim = abstractItemModel()) { + // A valid QModelIndex is needed for resolveModelItem() to match + // items in the release cache rather than just delegate type alone. + const int row = m_adaptorModel.rowAt(index); + const int column = m_adaptorModel.columnAt(index); + modelIndex = aim->index(row, column); + } + + if (QQmlDelegateModelItem *modelItem = resolveModelItem(index, modelIndex)) { + // Return the incubated object, or start an async incubation task and return nullptr for now + return incubateModelItemIfNeeded(modelItem, incubationMode); + } - // Return the incubated object, or start an async incubation task and return nullptr for now - return incubateModelItemIfNeeded(modelItem, incubationMode); -} - -QObject *QQmlTableInstanceModel::object(const QModelIndex &modelIndex, QQmlIncubator::IncubationMode incubationMode) -{ - Q_ASSERT(m_delegate); - Q_ASSERT(m_adaptorModel.adaptsAim()); - - const int flatIndex = m_adaptorModel.indexAt(modelIndex.row(), modelIndex.column()); - QQmlDelegateModelItem *modelItem = resolveModelItem(flatIndex, modelIndex); - if (!modelItem) - return nullptr; - - // Return the incubated object, or start an async incubation task and return nullptr for now - return incubateModelItemIfNeeded(modelItem, incubationMode); + return nullptr; } --- a/src/qmlmodels/qqmltableinstancemodel_p.h +++ b/src/qmlmodels/qqmltableinstancemodel_p.h @@ -87,5 +87,4 @@ QObject *object(int index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested) override; - QObject *object(const QModelIndex &index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested); QObject *incubateModelItemIfNeeded(QQmlDelegateModelItem *modelItem, QQmlIncubator::IncubationMode incubationMode); void restoreFromReleasedItemsCache(QQmlDelegateModelItem *item, int newFlatIndex); --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -2827,17 +2827,9 @@ bool ownItem = false; - QObject* object = nullptr; - const QAbstractItemModel *aim = model->abstractItemModel(); const int modelRow = isTransposed ? logicalColumnIndex(cell.y()) : logicalRowIndex(cell.y()); const int modelColumn = isTransposed ? logicalRowIndex(cell.x()) : logicalColumnIndex(cell.x()); const int modelIndex = modelIndexAtCell(QPoint(modelColumn, modelRow)); - if (tableModel && aim) { - // Prefer loading via QModelIndex so that QQmlTableInstanceModel can also - // match recently released items by model index, not just by delegate type. - object = tableModel->object(aim->index(modelRow, modelColumn), incubationMode); - } else { - object = model->object(modelIndex, incubationMode); - } + QObject *object = model->object(modelIndex, incubationMode); if (!object) {