From c3faf45f753fa7cf72862baa157205f6fcf93a1c Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby Date: Tue, 26 May 2026 16:36:27 +0200 Subject: [PATCH] SolverLogFileWindow: Add exeption to fix crash for #48. --- src/View/RunSolver/Log/Window.py | 34 +++++++++++++++++++------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/View/RunSolver/Log/Window.py b/src/View/RunSolver/Log/Window.py index 3bd0df70..217275a7 100644 --- a/src/View/RunSolver/Log/Window.py +++ b/src/View/RunSolver/Log/Window.py @@ -20,7 +20,7 @@ import tempfile import os from queue import Queue -from tools import trace, timer +from tools import trace, timer, logger_exception from View.Tools.PamhyrWindow import PamhyrDialog, PamhyrWindow @@ -81,25 +81,31 @@ class SolverLogFileWindow(PamhyrWindow): self.open_on_editor) def setup_text(self): - with open(self._file_name, "r") as f: - for line in f: - line = line.rstrip() - self.find(QTextEdit, "textEdit").append(line) + try: + with open(self._file_name, "r") as f: + for line in f: + line = line.rstrip() + self.find(QTextEdit, "textEdit").append(line) + except Exception as e: + logger_exception(e) def revert(self): self.find(QTextEdit, "textEdit").clear() self.setup_text() def open_on_editor(self): - p = QProcess(self) + try: + p = QProcess(self) - cmd = self._config.editor - cmd = cmd.replace("@file", self._file_name) + cmd = self._config.editor + cmd = cmd.replace("@file", self._file_name) - cmd = cmd.split() - exe = cmd[0] - args = cmd[1:] + cmd = cmd.split() + exe = cmd[0] + args = cmd[1:] - p.start( - exe, args, - ) + p.start( + exe, args, + ) + except Exception as e: + logger_exception(e)