History

first cut at properly shutting down timers while shutting down scripts

ZappoMan committed 11 years ago

Commit 7e2d3551 parent 1efa7b22 files · +15 −0Browse files

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

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+14−0
@@ -535,6 +535,9 @@ void ScriptEngine::run() { · 534 unmodified lines
535 }535 }
536 lastUpdate = now;536 lastUpdate = now;
537 }537 }
538
539 stopAllTimers(); // make sure all our timers are stopped if the script is ending
540
538 emit scriptEnding();541 emit scriptEnding();
539 542
540 // kill the avatar identity timer543 // kill the avatar identity timer
@@ -564,6 +567,17 @@ void ScriptEngine::run() { · 23 unmodified lines
564 emit doneRunning();567 emit doneRunning();
565}568}
566 569
570// NOTE: This is private because it must be called on the same thread that created the timers, which is why
571// we want to only call it in our own run "shutdown" processing.
572void ScriptEngine::stopAllTimers() {
573 QMutableHashIterator<QTimer*, QScriptValue> i(_timerFunctionMap);
574 while (i.hasNext()) {
575 i.next();
576 QTimer* timer = i.key();
577 stopTimer(timer);
578 }
579}
580
567void ScriptEngine::stop() {581void ScriptEngine::stop() {
568 _isFinished = true;582 _isFinished = true;
569 emit runningStateChanged();583 emit runningStateChanged();