summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2020-07-01 09:38:24 +0200
committerAndy Shaw <andy.shaw@qt.io>2020-07-18 11:30:32 +0200
commit5a20af684cf61192d4823869c3a55af7b3c0141e (patch)
tree787451cc7bc4f1b51e7bd239b89ceb45474aef5c
parente5fb9e4ceabc2f1bfd89d3b3cb0a69c7d74df5b8 (diff)
downloadqtquickcontrols-5a20af684cf61192d4823869c3a55af7b3c0141e.tar.gz
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 <mitch.curtis@qt.io>
-rw-r--r--src/controls/Private/qquicktreemodeladaptor.cpp2
-rw-r--r--src/controls/Private/qquicktreemodeladaptor_p.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/controls/Private/qquicktreemodeladaptor.cpp b/src/controls/Private/qquicktreemodeladaptor.cpp
index f1c8e413..10400815 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 9a272936..aaec6414 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;