]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix crash when disabling "Show in groups"
authorFrank Reininghaus <frank78ac@googlemail.com>
Wed, 14 Aug 2013 21:40:02 +0000 (23:40 +0200)
committerFrank Reininghaus <frank78ac@googlemail.com>
Wed, 14 Aug 2013 21:40:02 +0000 (23:40 +0200)
The problem was that items are removed from m_visibleGroups while
a QMutableHashIterator iterates over this hash, such that the iterator
can become invalid. The solution is to use a QHashIterator instead,
which takes a copy of the hash. Therefore, it is not affected if
m_visibleGroups is modified in any way.

BUG: 323248
FIXED-IN: 4.11.1
REVIEW: 111919

src/kitemviews/kitemlistview.cpp

index 0c3183cd5717c19ac719022764b968791801fe4a..7f15261511b3f77f19beb38b1f350b57ca952d7a 100644 (file)
@@ -1237,8 +1237,10 @@ void KItemListView::slotGroupedSortingChanged(bool current)
     if (m_grouped) {
         updateGroupHeaderHeight();
     } else {
-        // Clear all visible headers
-        QMutableHashIterator<KItemListWidget*, KItemListGroupHeader*> it (m_visibleGroups);
+        // Clear all visible headers. Note that the QHashIterator takes a copy of
+        // m_visibleGroups. Therefore, it remains valid even if items are removed
+        // from m_visibleGroups in recycleGroupHeaderForWidget().
+        QHashIterator<KItemListWidget*, KItemListGroupHeader*> it(m_visibleGroups);
         while (it.hasNext()) {
             it.next();
             recycleGroupHeaderForWidget(it.key());