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
This commit is contained in:
RndName 2022-04-14 13:48:23 +02:00
parent 4b89220a7b
commit aae314ae1d
No known key found for this signature in database
GPG Key ID: 5EF516FD9537F7C0

View File

@ -206,9 +206,11 @@ class QWaitingForMissionResultWindow(QDialog):
DebriefingFileWrittenSignal.get_instance().sendDebriefing(debriefing) DebriefingFileWrittenSignal.get_instance().sendDebriefing(debriefing)
except Exception: except Exception:
logging.exception("Got an error while sending debriefing") logging.exception("Got an error while sending debriefing")
self.wait_thread = self.sim_controller.wait_for_debriefing( if not debriefing.state_data.mission_ended:
lambda d: self.on_debriefing_update(d) # Wait for more changes
) self.wait_thread = self.sim_controller.wait_for_debriefing(
lambda d: self.on_debriefing_update(d)
)
def process_debriefing(self): def process_debriefing(self):
with logged_duration("Turn processing"): with logged_duration("Turn processing"):
@ -231,7 +233,10 @@ class QWaitingForMissionResultWindow(QDialog):
file = QFileDialog.getOpenFileName( file = QFileDialog.getOpenFileName(
self, "Select game file to open", filter="json(*.json)", dir="." self, "Select game file to open", filter="json(*.json)", dir="."
) )
logging.debug("Processing manually submitted %s", file[0]) if file[0] != "":
self.on_debriefing_update( logging.debug("Processing manually submitted %s", file[0])
self.sim_controller.debrief_current_state(Path(file[0], force_end=True)) # 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))
)