History

Fixes concurrency issue with scriptengine timers

Atlante45 committed 12 years ago

Commit 3d8f3ad1 parent 76f78e71 file · +6 −6Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+6−6
@@ -605,18 +605,18 @@ void ScriptEngine::stop() { · 604 unmodified lines
605605
606606 void ScriptEngine::timerFired() {
607607 QTimer* callingTimer = reinterpret_cast<QTimer*>(sender());
608−
609− // call the associated JS function, if it exists
610608 QScriptValue timerFunction = _timerFunctionMap.value(callingTimer);
611− if (timerFunction.isValid()) {
612− timerFunction.call();
613− }
614−
609+
615610 if (!callingTimer->isActive()) {
616611 // this timer is done, we can kill it
617612 _timerFunctionMap.remove(callingTimer);
618613 delete callingTimer;
619614 }
615+
616+ // call the associated JS function, if it exists
617+ if (timerFunction.isValid()) {
618+ timerFunction.call();
619+ }
620620 }
621621
622622 QObject* ScriptEngine::setupTimerWithInterval(const QScriptValue& function, int intervalMS, bool isSingleShot) {