From 5a20af684cf61192d4823869c3a55af7b3c0141e Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 1 Jul 2020 09:38:24 +0200 Subject: Return QPersistentModelIndex which is stored when calling mapRowToIndex Since the index is stored as a QPersistentModelIndex then this is what should be returned since a QModelIndex can become invalid and to prevent issues with views that may store this index we should keep it as a QPersistentModelIndex so that it is updated if the model changes it. Pick-to: 5.12 Fixes: QTBUG-84853 Change-Id: I0cf8014b386a2a5156f6c2d4f8b6feea823fbe26 Reviewed-by: Mitch Curtis --- src/controls/Private/qquicktreemodeladaptor.cpp | 2 +- src/controls/Private/qquicktreemodeladaptor_p.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controls/Private/qquicktreemodeladaptor.cpp b/src/controls/Private/qquicktreemodeladaptor.cpp index f1c8e4130..104008151 100644 --- a/src/controls/Private/qquicktreemodeladaptor.cpp +++ b/src/controls/Private/qquicktreemodeladaptor.cpp @@ -266,7 +266,7 @@ const QModelIndex &QQuickTreeModelAdaptor1::mapToModel(const QModelIndex &index) return m_items.at(index.row()).index; } -QModelIndex QQuickTreeModelAdaptor1::mapRowToModelIndex(int row) const +QPersistentModelIndex QQuickTreeModelAdaptor1::mapRowToModelIndex(int row) const { if (!m_model) return QModelIndex(); diff --git a/src/controls/Private/qquicktreemodeladaptor_p.h b/src/controls/Private/qquicktreemodeladaptor_p.h index 9a272936e..aaec6414b 100644 --- a/src/controls/Private/qquicktreemodeladaptor_p.h +++ b/src/controls/Private/qquicktreemodeladaptor_p.h @@ -95,7 +95,7 @@ public: bool childrenVisible(const QModelIndex &index); const QModelIndex &mapToModel(const QModelIndex &index) const; - Q_INVOKABLE QModelIndex mapRowToModelIndex(int row) const; + Q_INVOKABLE QPersistentModelIndex mapRowToModelIndex(int row) const; Q_INVOKABLE QItemSelection selectionForRowRange(const QModelIndex &fromIndex, const QModelIndex &toIndex) const; -- cgit v1.2.3