]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Use QMutableHashIterator for deleting items from a QHash
authorFrank Reininghaus <frank78ac@googlemail.com>
Tue, 11 Mar 2014 08:07:23 +0000 (09:07 +0100)
committerFrank Reininghaus <frank78ac@googlemail.com>
Tue, 11 Mar 2014 08:07:23 +0000 (09:07 +0100)
KItemListViewAnimation::slotFinished() used a QHashIterator to iterate
over a QHash, and then removes an item from the hash using
QHash::remove() inside the loop.

This is quite unusual - the recommended way is to use a
QMutableHashIterator (or std-style iterators and then QHash::erase(it)).

This might be related to the cause of a crash in this function.

BUG: 331876
REVIEW: 116666
FIXED-IN: 4.13.0

src/kitemviews/private/kitemlistviewanimation.cpp

index e347c5bb113a97c7fa4eb2ec4c1f308d2dcffdb9..5a00c8c3a6a9cb018444ac453037c0d56999370f 100644 (file)
@@ -225,13 +225,13 @@ void KItemListViewAnimation::slotFinished()
 {
     QPropertyAnimation* finishedAnim = qobject_cast<QPropertyAnimation*>(sender());
     for (int type = 0; type < AnimationTypeCount; ++type) {
-        QHashIterator<QGraphicsWidget*, QPropertyAnimation*> it(m_animation[type]);
+        QMutableHashIterator<QGraphicsWidget*, QPropertyAnimation*> it(m_animation[type]);
         while (it.hasNext()) {
             it.next();
             QPropertyAnimation* propertyAnim = it.value();
             if (propertyAnim == finishedAnim) {
                 QGraphicsWidget* widget = it.key();
-                m_animation[type].remove(widget);
+                it.remove();
                 finishedAnim->deleteLater();
 
                 emit finished(widget, static_cast<AnimationType>(type));