Copy container in Component::cleanUp before interating

Authored by fvogt on Apr 18 2019, 12:32 PM.

Description

Copy container in Component::cleanUp before interating

Summary:
Crash was reported:

Thread 1 (Thread 0x7fdc95c68800 (LWP 6402)):
[KCrash Handler]
#6 QHashData::nextNode (node=node@entry=0x562f53ffbd10) at tools/qhash.cpp:598
#7 0x00007fdc95a1fbab in QHash<QString, GlobalShortcut*>::const_iterator::operator++ (this=<synthetic pointer>) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qhash.h:395
#8 KdeDGlobalAccel::Component::cleanUp (this=0x562f53ffb040) at ./src/runtime/component.cpp:163

Apparently the container is modified while iterating over it. That does not work with the range-for as it does not detach, as opposed to Q_FOREACH.

Test Plan: @lbeltrame saw valgrind errors before applying this, but those disappeared with this patch.

Reviewers: Frameworks, davidedmundson

Reviewed By: davidedmundson

Subscribers: lbeltrame, kde-frameworks-devel

Tags: Frameworks

Differential Revision: https://phabricator.kde.org/D20659

Details

Committed
fvogtApr 18 2019, 1:16 PM
Reviewer
davidedmundson
Differential Revision
D20659: Copy container in Component::cleanUp before interating
Parents
R268:abe32ec59939: Don't use qAsConst over a temporary variable
Branches
Unknown
Tags
Unknown