Skip to content

Commit ad77e8e

Browse files
committed
fix: stabilisation du SDK en mode headless et nettoyage des processus sur échec BCASL
1 parent 3df2c7a commit ad77e8e

2 files changed

Lines changed: 35 additions & 13 deletions

File tree

Plugins_SDK/GeneralContext/Dialog.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,25 @@ def progress(
149149
) -> ProgressDialog:
150150
"""Create and return a ProgressDialog from Core.dialogs.
151151
152-
Uses Core.dialogs.ProgressDialog to ensure:
153-
- Theme inheritance from the application
154-
- Visual integration with the main application
155-
- Thread safety
156-
157-
Args:
158-
title: Dialog title
159-
text: Initial dialog text
160-
maximum: Maximum value (0 = indeterminate)
161-
cancelable: If True, show a Cancel button
162-
163-
Returns:
164-
ProgressDialog instance from Core.dialogs
152+
Uses Core.dialogs.ProgressDialog when GUI is available,
153+
otherwise returns a console-based fallback.
165154
"""
155+
from PySide6.QtWidgets import QApplication
156+
if QApplication.instance() is None:
157+
# Fallback for headless/sandbox mode
158+
class ConsoleProgress:
159+
def __init__(self, title):
160+
self.title = title
161+
self._canceled = False
162+
def show(self): print(f"[PROGRESS:START] {self.title}")
163+
def set_message(self, msg): print(f"[PROGRESS:MSG] {msg}")
164+
def set_status(self, msg): print(f"[PROGRESS:STATUS] {msg}")
165+
def set_progress(self, val, total=None):
166+
if total: print(f"[PROGRESS:VALUE] {val}/{total}")
167+
else: print(f"[PROGRESS:VALUE] {val}%")
168+
def close(self): print(f"[PROGRESS:END] {self.title}")
169+
def is_canceled(self): return False
170+
171+
return ConsoleProgress(title) # type: ignore
172+
166173
return ProgressDialog(title=title, cancelable=cancelable)

Ui/Gui/Dialogs/CompilerDialog.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,11 @@ def _after_bcasl(_report=None) -> None:
301301
"❌ Échec de la validation BCASL. La compilation ne peut pas continuer.",
302302
"❌ BCASL validation failed. Compilation cannot continue.",
303303
)
304+
try:
305+
from Ui.Gui.Dialogs.BcaslDialog import ensure_bcasl_thread_stopped
306+
ensure_bcasl_thread_stopped(self)
307+
except Exception:
308+
pass
304309
self.set_controls_enabled(True)
305310
return
306311

@@ -427,6 +432,11 @@ def _after_bcasl(_report=None) -> None:
427432
return
428433

429434
if not bcasl_report_allows_compile(self, _report):
435+
try:
436+
from Ui.Gui.Dialogs.BcaslDialog import ensure_bcasl_thread_stopped
437+
ensure_bcasl_thread_stopped(self)
438+
except Exception:
439+
pass
430440
self.set_controls_enabled(True)
431441
return
432442

@@ -588,6 +598,11 @@ def _after_bcasl(_report=None) -> None:
588598
"❌ Échec de la validation BCASL. La compilation ne peut pas continuer.",
589599
"❌ BCASL validation failed. Compilation cannot continue.",
590600
)
601+
try:
602+
from Ui.Gui.Dialogs.BcaslDialog import ensure_bcasl_thread_stopped
603+
ensure_bcasl_thread_stopped(self)
604+
except Exception:
605+
pass
591606
self.set_controls_enabled(True)
592607
return
593608

0 commit comments

Comments
 (0)