Skip to content
  • Eike Hein's avatar
    Fix QSortFilterProxyModelPrivate::updateChildrenMapping crash in libtaskmanager · d2f722a8
    Eike Hein authored and David Edmundson's avatar David Edmundson committed
    Summary:
    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 mappin...
    d2f722a8