diff options
author | Stephen Kelly <steveire@gmail.com> | 2016-12-20 00:44:12 +0000 |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2016-12-21 01:37:50 +0000 |
commit | baad82d242a4d8c1af6c87faaa7f25584183fd53 (patch) | |
tree | f0330b51b906160732d331c14e14e5193151a0a9 /src/corelib/itemmodels | |
parent | 0874861bcc70313c343aba5e5566ed30b69eed1c (diff) |
QIPM: Persist model indexes after emitting layoutChange, not before
Callers can persist a QModelIndex which was not persisted before in a
slot connected to the signal, and such a persisted index must be updated
in the course of the layoutChange.
Store the indexes to persist after emitting the signal.
Task-number: QTBUG-32981
Change-Id: Ibee4c0d84817d72603a03fe5b22fdeefeac0695e
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/corelib/itemmodels')
-rw-r--r-- | src/corelib/itemmodels/qidentityproxymodel.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/corelib/itemmodels/qidentityproxymodel.cpp b/src/corelib/itemmodels/qidentityproxymodel.cpp index e537793146..7c306799d0 100644 --- a/src/corelib/itemmodels/qidentityproxymodel.cpp +++ b/src/corelib/itemmodels/qidentityproxymodel.cpp @@ -496,15 +496,6 @@ void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList<QPe { Q_Q(QIdentityProxyModel); - const auto proxyPersistentIndexes = q->persistentIndexList(); - for (const QPersistentModelIndex &proxyPersistentIndex : proxyPersistentIndexes) { - proxyIndexes << proxyPersistentIndex; - Q_ASSERT(proxyPersistentIndex.isValid()); - const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex); - Q_ASSERT(srcPersistentIndex.isValid()); - layoutChangePersistentIndexes << srcPersistentIndex; - } - QList<QPersistentModelIndex> parents; parents.reserve(sourceParents.size()); for (const QPersistentModelIndex &parent : sourceParents) { @@ -518,6 +509,15 @@ void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList<QPe } q->layoutAboutToBeChanged(parents, hint); + + const auto proxyPersistentIndexes = q->persistentIndexList(); + for (const QPersistentModelIndex &proxyPersistentIndex : proxyPersistentIndexes) { + proxyIndexes << proxyPersistentIndex; + Q_ASSERT(proxyPersistentIndex.isValid()); + const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex); + Q_ASSERT(srcPersistentIndex.isValid()); + layoutChangePersistentIndexes << srcPersistentIndex; + } } void QIdentityProxyModelPrivate::_q_sourceLayoutChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint) |