Fix possible crash when disabling grouping

Review Request #111919 - Created Aug. 6, 2013 and submitted

Information
Frank Reininghaus
kde-baseapps
KDE/4.11
323248
Reviewers
dolphin
Sometimes when enabling and then disabling grouping, I get a crash.

I think the problem is that KItemListView::slotGroupedSortingChanged(bool current) uses a QMutableHashIterator to iterate through the groups while they are being removed. The problem is that they are not removed using the iterator, but by another function inside the loop. The iterator can thus become invalid, and iterating further can cause all sorts of trouble if we are unlucky.

The solution is to use a QHashIterator. This iterator creates an internal copy of the container which is not modified when elements are being removed.
Cannot reproduce the crash any more.
Mark Gaiser
Emmanuel Pescosta
Commit Hook
Frank Reininghaus
Review request changed

Status: Closed (submitted)

Loading...