From 549124aadd43d6fcea706afa23150927a249d6aa Mon Sep 17 00:00:00 2001 From: falkTX Date: Sat, 21 Jul 2018 21:36:18 +0200 Subject: [PATCH] Don't show quit confirmation dialog when running as plugin --- source/carla_host.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/source/carla_host.py b/source/carla_host.py index 3d1b2f4b4..48971caa6 100644 --- a/source/carla_host.py +++ b/source/carla_host.py @@ -2301,15 +2301,21 @@ class HostWindow(QMainWindow): # -------------------------------------------------------------------------------------------------------- # close event - def closeEvent(self, event): - if self.fCustomStopAction != self.CUSTOM_ACTION_APP_CLOSE and self.fSavedSettings[CARLA_KEY_MAIN_CONFIRM_EXIT]: - ask = QMessageBox.question(self, self.tr("Quit"), - self.tr("Are you sure you want to quit Carla?"), - QMessageBox.Yes|QMessageBox.No) + def shouldIgnoreClose(self): + if self.host.isControl or self.host.isPlugin: + return False + if self.fCustomStopAction == self.CUSTOM_ACTION_APP_CLOSE: + return False + if self.fSavedSettings[CARLA_KEY_MAIN_CONFIRM_EXIT]: + return QMessageBox.question(self, self.tr("Quit"), + self.tr("Are you sure you want to quit Carla?"), + QMessageBox.Yes|QMessageBox.No) == QMessageBox.No + return False - if ask == QMessageBox.No: - event.ignore() - return + def closeEvent(self, event): + if self.shouldIgnoreClose(): + event.ignore() + return self.killTimers() self.saveSettings()