From aae314ae1de0bd38ccb7bb1e1f27545d522a80da Mon Sep 17 00:00:00 2001 From: RndName Date: Thu, 14 Apr 2022 13:48:23 +0200 Subject: [PATCH] Fix debriefing wait thread not closing correctly - now stops the thread when manually submitting results - added check for mission_end state on debrief update to prevent creating another waiting thread when the mission is already over - also fixed an issue when manually submitting but canceling the file open dialog. closes #2165 --- .../windows/QWaitingForMissionResultWindow.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/qt_ui/windows/QWaitingForMissionResultWindow.py b/qt_ui/windows/QWaitingForMissionResultWindow.py index 37c64d84..d8695ea9 100644 --- a/qt_ui/windows/QWaitingForMissionResultWindow.py +++ b/qt_ui/windows/QWaitingForMissionResultWindow.py @@ -206,9 +206,11 @@ class QWaitingForMissionResultWindow(QDialog): DebriefingFileWrittenSignal.get_instance().sendDebriefing(debriefing) except Exception: logging.exception("Got an error while sending debriefing") - self.wait_thread = self.sim_controller.wait_for_debriefing( - lambda d: self.on_debriefing_update(d) - ) + if not debriefing.state_data.mission_ended: + # Wait for more changes + self.wait_thread = self.sim_controller.wait_for_debriefing( + lambda d: self.on_debriefing_update(d) + ) def process_debriefing(self): with logged_duration("Turn processing"): @@ -231,7 +233,10 @@ class QWaitingForMissionResultWindow(QDialog): file = QFileDialog.getOpenFileName( self, "Select game file to open", filter="json(*.json)", dir="." ) - logging.debug("Processing manually submitted %s", file[0]) - self.on_debriefing_update( - self.sim_controller.debrief_current_state(Path(file[0], force_end=True)) - ) + if file[0] != "": + logging.debug("Processing manually submitted %s", file[0]) + # Stop the current waiting thread as we manually submit the results + self.wait_thread.stop() + self.on_debriefing_update( + self.sim_controller.debrief_current_state(Path(file[0], force_end=True)) + )