Skip to content

Commit 650aafe

Browse files
committed
merge main2
2 parents 032c417 + e1b0b07 commit 650aafe

22 files changed

Lines changed: 541 additions & 2197 deletions

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,7 @@ security-*.json
210210
# Pre-commit
211211
.pre-commit-config.yaml.bak
212212

213-
# Exclude tests folder
214-
tests/
213+
215214

216215
#PREFERENCE
217216
.pref

Core/Auto_Command_Builder/auto_build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
# Optional access to registered engines for discovery
2424
try:
25-
from Core.engines_loader import registry as engines_registry # type: ignore
25+
from ..engines_loader import registry as engines_registry # type: ignore
2626
except Exception: # pragma: no cover
2727
engines_registry = None # type: ignore
2828

Core/Compiler/mainprocess.py

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -180,26 +180,7 @@ def start_compilation_process(self, file):
180180
process._cancel_file = cancel_file
181181
process.readyReadStandardOutput.connect(lambda p=process: self.handle_stdout(p))
182182
process.readyReadStandardError.connect(lambda p=process: self.handle_stderr(p))
183-
184-
# Capture stderr data before process deletion to avoid accessing deleted C++ object
185-
def _on_finished(ec, es, p=process):
186-
try:
187-
# Save stderr data before process is deleted
188-
p._final_stderr = p.readAllStandardError().data().decode()
189-
except Exception:
190-
p._final_stderr = ""
191-
try:
192-
self.handle_finished(p, ec, es)
193-
except Exception:
194-
pass
195-
finally:
196-
# Schedule deletion after handle_finished completes
197-
try:
198-
p.deleteLater()
199-
except Exception:
200-
pass
201-
202-
process.finished.connect(_on_finished)
183+
process.finished.connect(lambda ec, es, p=process: self.handle_finished(p, ec, es))
203184
self.processes.append(process)
204185
self.current_compiling.add(file)
205186
# Optional: update dependent UI states
@@ -694,12 +675,15 @@ def handle_finished(self, process, exit_code, exit_status):
694675
self.log.append(
695676
f"<span style='color:red;'>Détails de l'erreur :<br><pre>{error_details}</pre></span>"
696677
)
697-
self.show_error_dialog(file_basename, file, exit_code, error_details)
698-
678+
try :
679+
self.show_error_dialog(file_basename, file, exit_code, error_details)
680+
699681
# Auto-install modules manquants si activé
700-
if self.opt_auto_install.isChecked():
701-
self.try_install_missing_modules(process)
682+
if self.opt_auto_install.isChecked():
683+
self.try_install_missing_modules(process)
702684

685+
except :
686+
pass
703687
if process in self.processes:
704688
self.processes.remove(process)
705689
if file in self.current_compiling:

Core/MainWindow.py

Lines changed: 5 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
import threading
2323
from typing import Optional
2424

25-
from PySide6.QtCore import QObject, QProcess, Qt, QTimer, Signal
25+
from PySide6.QtCore import QProcess, Qt
2626
from PySide6.QtGui import QDropEvent, QPixmap
2727
from PySide6.QtWidgets import QApplication, QFileDialog, QMessageBox, QWidget
28+
29+
from .utils import _UiInvoker, _run_coro_async
2830
from .dialogs import ProgressDialog, CompilationProcessDialog
2931
from .Venv_Manager import VenvManager
3032

@@ -56,53 +58,6 @@ def get_selected_workspace() -> Optional[str]:
5658
return None
5759

5860

59-
class _UiInvoker(QObject):
60-
_sig = Signal(object)
61-
62-
def __init__(self, parent=None):
63-
super().__init__(parent)
64-
self._sig.connect(self._exec, Qt.QueuedConnection)
65-
66-
def post(self, fn):
67-
try:
68-
self._sig.emit(fn)
69-
except Exception:
70-
pass
71-
72-
def _exec(self, fn):
73-
try:
74-
fn()
75-
except Exception:
76-
pass
77-
78-
79-
def _run_coro_async(coro, on_result, ui_owner=None):
80-
invoker = None
81-
try:
82-
if ui_owner is not None and isinstance(ui_owner, QObject):
83-
invoker = getattr(ui_owner, "_ui_invoker", None)
84-
if invoker is None:
85-
invoker = _UiInvoker(ui_owner)
86-
setattr(ui_owner, "_ui_invoker", invoker)
87-
except Exception:
88-
invoker = None
89-
90-
def _runner():
91-
try:
92-
res = asyncio.run(coro)
93-
except Exception as e:
94-
res = e
95-
try:
96-
if invoker is not None:
97-
invoker.post(lambda: on_result(res))
98-
else:
99-
QTimer.singleShot(0, lambda: on_result(res))
100-
except Exception:
101-
pass
102-
103-
threading.Thread(target=_runner, daemon=True).start()
104-
105-
10661
# Synchronous request from background threads to change workspace via GUI thread
10762
# Ensures confirmation dialog is shown and result returned to caller
10863
from PySide6.QtCore import QEventLoop as _QEventLoop
@@ -1117,7 +1072,7 @@ def show_statistics(self):
11171072
# Internationalization using JSON language files
11181073
current_language = "English"
11191074

1120-
def _apply_translations(self, tr: dict):
1075+
def _apply_main_app_translations(self, tr: dict):
11211076
# Utilitaires internes pour éviter les valeurs codées en dur
11221077
def _set(attr: str, key: str, method: str = "setText"):
11231078
try:
@@ -1202,7 +1157,7 @@ def _on_result(res):
12021157
if isinstance(res, Exception):
12031158
return
12041159
code, tr = res
1205-
self._apply_translations(tr)
1160+
self._apply_main_app_translations(tr)
12061161
# Notifier les moteurs pour rafraîchir leurs libellés (i18n)
12071162
try:
12081163
# Callback-based refresh (legacy)

0 commit comments

Comments
 (0)