first cut at properly shutting down timers while shutting down scripts

This commit is contained in:
ZappoMan 2015-02-23 11:40:30 -08:00
parent 1efa7b28b0
commit 7e2d355b56
2 changed files with 15 additions and 0 deletions

View file

@ -535,6 +535,9 @@ void ScriptEngine::run() {
}
lastUpdate = now;
}
stopAllTimers(); // make sure all our timers are stopped if the script is ending
emit scriptEnding();
// kill the avatar identity timer
@ -564,6 +567,17 @@ void ScriptEngine::run() {
emit doneRunning();
}
// NOTE: This is private because it must be called on the same thread that created the timers, which is why
// we want to only call it in our own run "shutdown" processing.
void ScriptEngine::stopAllTimers() {
QMutableHashIterator<QTimer*, QScriptValue> i(_timerFunctionMap);
while (i.hasNext()) {
i.next();
QTimer* timer = i.key();
stopTimer(timer);
}
}
void ScriptEngine::stop() {
_isFinished = true;
emit runningStateChanged();

View file

@ -141,6 +141,7 @@ protected:
int _numAvatarSoundSentBytes;
private:
void stopAllTimers();
void sendAvatarIdentityPacket();
void sendAvatarBillboardPacket();