diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2015-01-14 00:25:26 +0100 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@theqtcompany.com> | 2015-01-22 08:31:28 +0100 |
commit | 2ecde56f65c21e91c2d7e9fe72ecb9c9d1ff1d33 (patch) | |
tree | b44663b01d7181dfbe0a444f4075de9de652ac6b /src/corelib | |
parent | 64c6bfd1f45f532ea32de49431b66e03e7593f01 (diff) |
QSortFilterProxyModel: fix a regression
bec1854cc023fb705319c582a636d5f484adafcc introduced a regression:
when sorting a tree model, children items would not follow the sorted
parents any more (they wouldn't be remapped correctly), resulting
in crashes.
So, the fix needs more reasoning; let's revert the fix,
but leave the original test around for any subsequent attempt, and
introduce a new test which looks for the right behavior when
sorting trees.
This commit partially reverts bec1854cc023fb705319c582a636d5f484adafcc.
Task-number: QTBUG-43827
Change-Id: Ic83ac53aef639f870f6c36a8b4b2992f5b485b13
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Volker Krause <volker.krause@kdab.com>
(cherry-picked from qtbase/e9ad46ed412987e3e46c5a641e5f30408b97ac90)
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/itemmodels/qsortfilterproxymodel.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index 0b2b0e4188..b01c9db418 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -1196,7 +1196,11 @@ void QSortFilterProxyModelPrivate::_q_sourceDataChanged(const QModelIndex &sourc parents << q->mapFromSource(source_parent); emit q->layoutAboutToBeChanged(parents, QAbstractItemModel::VerticalSortHint); QModelIndexPairList source_indexes = store_persistent_indexes(); - sort_source_rows(m->source_rows, source_parent); + remove_source_items(m->proxy_rows, m->source_rows, source_rows_resort, + source_parent, Qt::Vertical, false); + sort_source_rows(source_rows_resort, source_parent); + insert_source_items(m->proxy_rows, m->source_rows, source_rows_resort, + source_parent, Qt::Vertical, false); update_persistent_indexes(source_indexes); emit q->layoutChanged(parents, QAbstractItemModel::VerticalSortHint); // Make sure we also emit dataChanged for the rows |