Eike Hein <h...@kde.org> changed:
What |Removed |Added
Latest Commit| |https://commits.kde.org/pla
--- Comment #15 from Eike Hein <h...@kde.org> ---
Git commit 3990ec2358106875bd1d58ad65bd2a55ff4f1d73 by Eike Hein.
Committed on 07/08/2017 at 10:24.
Pushed by hein into branch 'master'.
Fix QSortFilterProxyModelPrivate::updateChildrenMapping crash in libtaskmanager
TaskGroupingProxyModel uses a simple QVector<QVector<int>> populated
with source model row indices to represent the task group tree. To
implement QAbstractItemModel::parent(), its implementation of index()
encodes row indices of the top-level vector into the internal ids of
child item model indices. This allows parent() to produce the parent
model index by simply decoding the parent row from the passed-in child
index and call index() with that row.
Top-level row indices shift up and down as the list of top-level items
changes, invalidating those internal ids. QModelIndex is not meant to
be stored, and the proxy model does take care of updating any persis-
tent model indexes with new ids, so this should be fine.
However, where it falls apart is that as internal ids are invalidated,
a QSortFilterProxyModel on top of this proxy (i.e. TasksModel) may end
up with multiple indexes with identical internal ids in its mappings,
causing it to mess up its mappings as it uses them (e.g. taking things
from them). This causes the often-reported crash/assert there.
The fix is to refactor index()/parent() not to rely on row indices as
internal ids, but instead use pointers to internal data structures
This patch achieves this by changing the map to QVector<QVector<int> *>.
This screams fugly, but the alternative would basically just be to
create some wrapper struct to hide the fugly appeareance a little,
which I don't think is worth it.
On the flip side, it saves a QVector::replace() call as a multable
vector iterator can work directly on a vector without making a copy,
and it's now no longer necessary to manually update the persistent
model indices beyond what endRemoveRows() does implicitly.
Reviewers: #plasma, davidedmundson
Differential Revision: https://phabricator.kde.org/D7139
M +54 -73 libtaskmanager/taskgroupingproxymodel.cpp
You are receiving this mail because:
You are watching all bug changes.