Fixes concurrency issue with scriptengine timers

This commit is contained in:
Atlante45 2014-09-19 13:21:24 -07:00
parent 76f78e77d1
commit 3d8f3ad9fa

View file

@ -605,18 +605,18 @@ void ScriptEngine::stop() {
void ScriptEngine::timerFired() {
QTimer* callingTimer = reinterpret_cast<QTimer*>(sender());
// call the associated JS function, if it exists
QScriptValue timerFunction = _timerFunctionMap.value(callingTimer);
if (timerFunction.isValid()) {
timerFunction.call();
}
if (!callingTimer->isActive()) {
// this timer is done, we can kill it
_timerFunctionMap.remove(callingTimer);
delete callingTimer;
}
// call the associated JS function, if it exists
if (timerFunction.isValid()) {
timerFunction.call();
}
}
QObject* ScriptEngine::setupTimerWithInterval(const QScriptValue& function, int intervalMS, bool isSingleShot) {