mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-19 00:11:21 +00:00
Use QMutableHashIterator for deleting items from a QHash
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
This commit is contained in:
parent
b892058730
commit
1cbb06f593
|
@ -225,13 +225,13 @@ void KItemListViewAnimation::slotFinished()
|
||||||
{
|
{
|
||||||
QPropertyAnimation* finishedAnim = qobject_cast<QPropertyAnimation*>(sender());
|
QPropertyAnimation* finishedAnim = qobject_cast<QPropertyAnimation*>(sender());
|
||||||
for (int type = 0; type < AnimationTypeCount; ++type) {
|
for (int type = 0; type < AnimationTypeCount; ++type) {
|
||||||
QHashIterator<QGraphicsWidget*, QPropertyAnimation*> it(m_animation[type]);
|
QMutableHashIterator<QGraphicsWidget*, QPropertyAnimation*> it(m_animation[type]);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
QPropertyAnimation* propertyAnim = it.value();
|
QPropertyAnimation* propertyAnim = it.value();
|
||||||
if (propertyAnim == finishedAnim) {
|
if (propertyAnim == finishedAnim) {
|
||||||
QGraphicsWidget* widget = it.key();
|
QGraphicsWidget* widget = it.key();
|
||||||
m_animation[type].remove(widget);
|
it.remove();
|
||||||
finishedAnim->deleteLater();
|
finishedAnim->deleteLater();
|
||||||
|
|
||||||
emit finished(widget, static_cast<AnimationType>(type));
|
emit finished(widget, static_cast<AnimationType>(type));
|
||||||
|
|
Loading…
Reference in a new issue