diff options
author | Jan Holthuis <jholthuis@mixxx.org> | 2022-01-16 01:17:49 +0100 |
---|---|---|
committer | Jan Holthuis <jholthuis@mixxx.org> | 2022-01-16 01:20:32 +0100 |
commit | 418a574c24ce17c756e666f7d313f62c3e1d5010 (patch) | |
tree | 1db9b6b7d6e3204e49cada2ffb2f36189c919520 | |
parent | 418a7e362abac709e753589c2201504b98191f20 (diff) |
ControllerScriptInterfaceLegacy: Do not modify QHash while iterating over it
Modifing `m_timers` via `ControllerScriptInterfaceLegacy::stopTimer()`
invalidates all iterators for `m_timers`. The old code only worked by
chance and triggers an assertion with Qt6.
-rw-r--r-- | src/controllers/scripting/legacy/controllerscriptinterfacelegacy.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/controllers/scripting/legacy/controllerscriptinterfacelegacy.cpp b/src/controllers/scripting/legacy/controllerscriptinterfacelegacy.cpp index 3ed6b54dd0..958cdadda5 100644 --- a/src/controllers/scripting/legacy/controllerscriptinterfacelegacy.cpp +++ b/src/controllers/scripting/legacy/controllerscriptinterfacelegacy.cpp @@ -42,10 +42,9 @@ ControllerScriptInterfaceLegacy::ControllerScriptInterfaceLegacy( ControllerScriptInterfaceLegacy::~ControllerScriptInterfaceLegacy() { // Stop all timers - QMutableHashIterator<int, TimerInfo> i(m_timers); - while (i.hasNext()) { - i.next(); - stopTimer(i.key()); + const auto timerIds = m_timers.keys(); + for (const int timerId : timerIds) { + stopTimer(timerId); } // Prevents leaving decks in an unstable state |