Skip to content

Commit 25a480e

Browse files
committed
corection
1 parent 0fe37fc commit 25a480e

14 files changed

Lines changed: 185 additions & 2285 deletions

File tree

Core/IdeLikeGui/connections.py

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -421,21 +421,9 @@ def _open_theme_dialog(self) -> None:
421421
def _open_bcasl_loader(self) -> None:
422422
"""Open BCASL dialog with a resilient runtime import path."""
423423
try:
424-
from importlib import import_module
424+
from ..UiConnection import _open_bcasl_loader_dialog
425425

426-
mod = import_module("bcasl.Loader")
427-
fn = getattr(mod, "open_bc_loader_dialog", None)
428-
if callable(fn):
429-
fn(self)
430-
return
431-
except Exception:
432-
pass
433-
try:
434-
import bcasl
435-
436-
fn2 = getattr(bcasl, "open_api_loader_dialog", None)
437-
if callable(fn2):
438-
fn2(self)
426+
_open_bcasl_loader_dialog(self)
439427
except Exception:
440428
pass
441429

@@ -515,16 +503,6 @@ def _connect_ide_like_signals(self) -> None:
515503
self.btn_nuitka_icon.clicked.connect(self.select_nuitka_icon)
516504
except Exception:
517505
pass
518-
try:
519-
if getattr(self, "btn_bc_loader", None):
520-
try:
521-
self.btn_bc_loader.clicked.disconnect()
522-
except Exception:
523-
pass
524-
self.btn_bc_loader.clicked.connect(lambda: _open_bcasl_loader(self))
525-
except Exception:
526-
pass
527-
528506
_bind_status_updates(self)
529507

530508

Core/UiConnection.py

Lines changed: 63 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -553,32 +553,7 @@ def _connect_text(widget, handler) -> None:
553553
_connect_text(self.file_filter_input, self.apply_file_filter)
554554

555555
if self.btn_bc_loader:
556-
try:
557-
from importlib import import_module
558-
559-
def _open_bc():
560-
try:
561-
# Preferred rich BCASL dialog (plugin config tabs).
562-
mod = import_module("bcasl.Loader")
563-
fn = getattr(mod, "open_bc_loader_dialog", None)
564-
if callable(fn):
565-
fn(self)
566-
return
567-
except Exception:
568-
pass
569-
try:
570-
# Fallback to exported API loader.
571-
import bcasl
572-
573-
fn2 = getattr(bcasl, "open_api_loader_dialog", None)
574-
if callable(fn2):
575-
fn2(self)
576-
except Exception:
577-
pass
578-
579-
self.btn_bc_loader.clicked.connect(_open_bc)
580-
except Exception:
581-
pass
556+
_connect_clicked(self.btn_bc_loader, lambda: _open_bcasl_loader_dialog(self))
582557

583558
_connect_clicked(self.btn_help, self.show_help_dialog)
584559

@@ -615,6 +590,68 @@ def update_compiler_options_enabled() -> None:
615590
_connect_clicked(self.btn_suggest_deps, self.suggest_missing_dependencies)
616591

617592

593+
def _open_bcasl_loader_dialog(self) -> None:
594+
"""Open BCASL loader with robust import fallbacks and visible diagnostics."""
595+
fn = None
596+
import_errors: list[str] = []
597+
try:
598+
if getattr(self, "log", None):
599+
self.log.append(self.tr("Ouverture BCASL...", "Opening BCASL..."))
600+
except Exception:
601+
pass
602+
603+
try:
604+
from bcasl.Loader import open_bc_loader_dialog as fn # type: ignore
605+
except Exception as e:
606+
import_errors.append(f"bcasl.Loader.open_bc_loader_dialog: {e}")
607+
fn = None
608+
609+
if fn is None:
610+
try:
611+
from bcasl import open_api_loader_dialog as fn # type: ignore
612+
except Exception as e:
613+
import_errors.append(f"bcasl.open_api_loader_dialog: {e}")
614+
fn = None
615+
616+
if fn is None:
617+
try:
618+
from bcasl.bcasl_loader import open_api_loader_dialog as fn # type: ignore
619+
except Exception as e:
620+
import_errors.append(f"bcasl.bcasl_loader.open_api_loader_dialog: {e}")
621+
fn = None
622+
623+
if fn is None:
624+
try:
625+
if getattr(self, "log", None):
626+
self.log.append(
627+
self.tr(
628+
"BCASL indisponible: impossible de charger le dialogue.",
629+
"BCASL unavailable: failed to load dialog.",
630+
)
631+
)
632+
for err in import_errors:
633+
self.log.append(f" - {err}")
634+
except Exception:
635+
pass
636+
return
637+
638+
try:
639+
fn(self)
640+
except Exception as e:
641+
try:
642+
if getattr(self, "log", None):
643+
self.log.append(
644+
self.tr(
645+
f"Erreur BCASL: {e}",
646+
f"BCASL error: {e}",
647+
)
648+
)
649+
for err in import_errors:
650+
self.log.append(f" - {err}")
651+
except Exception:
652+
pass
653+
654+
618655
def _show_initial_help_message(self) -> None:
619656
"""Affiche un message d'aide si aucun workspace n'est sélectionné."""
620657
# Désactivé à la demande : pas de message d'astuce par défaut dans le log.

0 commit comments

Comments
 (0)