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
605 605
606void ScriptEngine::timerFired() {606void ScriptEngine::timerFired() {
607 QTimer* callingTimer = reinterpret_cast<QTimer*>(sender());607 QTimer* callingTimer = reinterpret_cast<QTimer*>(sender());
608
609 // call the associated JS function, if it exists
610 QScriptValue timerFunction = _timerFunctionMap.value(callingTimer);608 QScriptValue timerFunction = _timerFunctionMap.value(callingTimer);
611 if (timerFunction.isValid()) {609
612 timerFunction.call();
613 }
614
615 if (!callingTimer->isActive()) {610 if (!callingTimer->isActive()) {
616 // this timer is done, we can kill it611 // this timer is done, we can kill it
617 _timerFunctionMap.remove(callingTimer);612 _timerFunctionMap.remove(callingTimer);
618 delete callingTimer;613 delete callingTimer;
619 }614 }
615
616 // call the associated JS function, if it exists
617 if (timerFunction.isValid()) {
618 timerFunction.call();
619 }
620}620}
621 621
622QObject* ScriptEngine::setupTimerWithInterval(const QScriptValue& function, int intervalMS, bool isSingleShot) {622QObject* ScriptEngine::setupTimerWithInterval(const QScriptValue& function, int intervalMS, bool isSingleShot) {