From b12c598776ceb88c4fcf9979a6fcf8441d0db73b Mon Sep 17 00:00:00 2001 From: falkTX Date: Sat, 15 Feb 2014 20:08:45 +0000 Subject: [PATCH] Prevent possible idle while engine is closing --- source/carla_host.py | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/source/carla_host.py b/source/carla_host.py index 918cd7a30..8ae5c50b1 100644 --- a/source/carla_host.py +++ b/source/carla_host.py @@ -718,6 +718,15 @@ class HostWindow(QMainWindow): # ----------------------------------------------------------------- # Internal stuff (gui) + def killTimers(self): + if self.fIdleTimerFast != 0: + self.killTimer(self.fIdleTimerFast) + self.fIdleTimerFast = 0 + + if self.fIdleTimerSlow != 0: + self.killTimer(self.fIdleTimerSlow) + self.fIdleTimerSlow = 0 + def setProperWindowTitle(self): title = self.fClientName @@ -1024,14 +1033,7 @@ class HostWindow(QMainWindow): @pyqtSlot() def slot_handleEngineStoppedCallback(self): - if self.fIdleTimerFast != 0: - self.killTimer(self.fIdleTimerFast) - self.fIdleTimerFast = 0 - - if self.fIdleTimerSlow != 0: - self.killTimer(self.fIdleTimerSlow) - self.fIdleTimerSlow = 0 - + self.killTimers() self.slot_engineStop(False) Carla.bufferSize = 0 @@ -1103,14 +1105,7 @@ class HostWindow(QMainWindow): QMainWindow.timerEvent(self, event) def closeEvent(self, event): - if self.fIdleTimerFast != 0: - self.killTimer(self.fIdleTimerFast) - self.fIdleTimerFast = 0 - - if self.fIdleTimerSlow != 0: - self.killTimer(self.fIdleTimerSlow) - self.fIdleTimerSlow = 0 - + self.killTimers() self.saveSettings() if Carla.host.is_engine_running(): @@ -1214,6 +1209,7 @@ def engineCallback(ptr, action, pluginId, value1, value2, value3, valueStr): elif action == ENGINE_CALLBACK_ENGINE_STARTED: Carla.gui.EngineStartedCallback.emit(value1, value2, valueStr) elif action == ENGINE_CALLBACK_ENGINE_STOPPED: + Carla.gui.killTimers() Carla.gui.EngineStoppedCallback.emit() elif action == ENGINE_CALLBACK_INFO: Carla.gui.InfoCallback.emit(valueStr)