Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 2 files). Show all
Unified · Split
| @@ -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 timer | 543 | // 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. | ||
| 572 | void 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 | |||
| 567 | void ScriptEngine::stop() { | 581 | void ScriptEngine::stop() { |
| 568 | _isFinished = true; | 582 | _isFinished = true; |
| 569 | emit runningStateChanged(); | 583 | emit runningStateChanged(); |