kopia lustrzana https://github.com/corrscope/corrscope
Show dialog if exceptions raised before playback begins
rodzic
d41f9998a3
commit
a289349d9c
|
@ -377,26 +377,29 @@ class MainWindow(qw.QMainWindow):
|
||||||
def play_thread(
|
def play_thread(
|
||||||
self, outputs: List[IOutputConfig], dlg: Optional["CorrProgressDialog"]
|
self, outputs: List[IOutputConfig], dlg: Optional["CorrProgressDialog"]
|
||||||
):
|
):
|
||||||
assert self.model
|
try:
|
||||||
|
assert self.model
|
||||||
|
|
||||||
arg = self._get_args(outputs)
|
arg = self._get_args(outputs)
|
||||||
cfg = copy_config(self.model.cfg)
|
cfg = copy_config(self.model.cfg)
|
||||||
t = self.corr_thread = CorrThread(cfg, arg)
|
t = self.corr_thread = CorrThread(cfg, arg)
|
||||||
|
|
||||||
if dlg:
|
if dlg:
|
||||||
dlg.canceled.connect(t.abort)
|
dlg.canceled.connect(t.abort)
|
||||||
t.arg = attr.evolve(
|
t.arg = attr.evolve(
|
||||||
arg,
|
arg,
|
||||||
on_begin=run_on_ui_thread(dlg.on_begin, (float, float)),
|
on_begin=run_on_ui_thread(dlg.on_begin, (float, float)),
|
||||||
progress=run_on_ui_thread(dlg.setValue, (int,)),
|
progress=run_on_ui_thread(dlg.setValue, (int,)),
|
||||||
is_aborted=t.is_aborted.get,
|
is_aborted=t.is_aborted.get,
|
||||||
on_end=run_on_ui_thread(dlg.reset, ()), # TODO dlg.close
|
on_end=run_on_ui_thread(dlg.reset, ()), # TODO dlg.close
|
||||||
)
|
)
|
||||||
|
|
||||||
t.finished.connect(self.on_play_thread_finished)
|
t.finished.connect(self.on_play_thread_finished)
|
||||||
t.error.connect(self.on_play_thread_error)
|
t.error.connect(self.on_play_thread_error)
|
||||||
t.ffmpeg_missing.connect(self.on_play_thread_ffmpeg_missing)
|
t.ffmpeg_missing.connect(self.on_play_thread_ffmpeg_missing)
|
||||||
t.start()
|
t.start()
|
||||||
|
except Exception as e:
|
||||||
|
TracebackDialog(self).showMessage(format_stack_trace(e))
|
||||||
|
|
||||||
def _get_args(self, outputs: List[IOutputConfig]):
|
def _get_args(self, outputs: List[IOutputConfig]):
|
||||||
arg = Arguments(cfg_dir=self.cfg_dir, outputs=outputs)
|
arg = Arguments(cfg_dir=self.cfg_dir, outputs=outputs)
|
||||||
|
@ -444,6 +447,14 @@ class MainWindow(qw.QMainWindow):
|
||||||
return self.model.cfg
|
return self.model.cfg
|
||||||
|
|
||||||
|
|
||||||
|
def format_stack_trace(e):
|
||||||
|
if isinstance(e, CorrError):
|
||||||
|
stack_trace = traceback.format_exc(limit=0)
|
||||||
|
else:
|
||||||
|
stack_trace = traceback.format_exc()
|
||||||
|
return stack_trace
|
||||||
|
|
||||||
|
|
||||||
class CorrThread(qc.QThread):
|
class CorrThread(qc.QThread):
|
||||||
is_aborted: Locked[bool]
|
is_aborted: Locked[bool]
|
||||||
|
|
||||||
|
@ -472,10 +483,7 @@ class CorrThread(qc.QThread):
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
arg.on_end()
|
arg.on_end()
|
||||||
if isinstance(e, CorrError):
|
stack_trace = format_stack_trace(e)
|
||||||
stack_trace = traceback.format_exc(limit=0)
|
|
||||||
else:
|
|
||||||
stack_trace = traceback.format_exc()
|
|
||||||
self.error.emit(stack_trace)
|
self.error.emit(stack_trace)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
Ładowanie…
Reference in New Issue