dev-qt/qtdeclarative: backport fix for QTBUG-146869

Signed-off-by: Ionen Wolkens <ionen@gentoo.org>
This commit is contained in:
Ionen Wolkens
2026-05-22 12:11:08 -04:00
parent f1e6a5e7b6
commit ab782209cc
2 changed files with 77 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
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) {

View File

@@ -32,6 +32,10 @@ BDEPEND="
~dev-qt/qtshadertools-${PV}:6
"
PATCHES=(
"${FILESDIR}"/${PN}-6.11.1-QTBUG-146869.patch
)
src_configure() {
local mycmakeargs=(
$(cmake_use_find_package qmlls Qt6LanguageServerPrivate)