11from abc import ABC , abstractmethod
22from logging import Logger
3- from typing import TYPE_CHECKING , Any , Callable
3+ from typing import TYPE_CHECKING
44
5+ from libbs .decompilers .ida .compat import execute_ui
56import ida_kernwin
67
78if TYPE_CHECKING :
@@ -13,7 +14,6 @@ class BaseCoordinator(ABC):
1314 """
1415 Base class providing:
1516 - Common references (app, factory, log)
16- - Thread-safe UI helpers (safe_* methods)
1717 - Authentication helpers (require_auth)
1818 """
1919
@@ -22,52 +22,30 @@ def __init__(self, *, app: "App", factory: "DialogFactory", log: Logger) -> None
2222 self .factory : "DialogFactory" = factory
2323 self .log : Logger = log
2424
25- # ======================================================
26- # IDA-safe helpers — executed on the UI thread safely
27- # ======================================================
28-
29- def safe_ui_exec (self , fn : Callable [[], Any ], fast : bool = True ) -> Any :
30- """Run a function safely on IDA’s main UI thread."""
31- try :
32- flags = ida_kernwin .MFF_FAST if fast else ida_kernwin .MFF_NOWAIT
33- return ida_kernwin .execute_sync (fn , flags )
34- except Exception as e :
35- print (f"[Coordinator] safe_ui_exec failed: { e } " )
36- self .log .error (f"[Coordinator] safe_ui_exec failed: { e } " )
37- return None
38-
39- def safe_info (self , msg : str ) -> None :
25+ @execute_ui
26+ def show_info_dialog (self , msg : str ) -> None :
4027 """Display an info dialog safely."""
28+ try :
29+ ida_kernwin .info (msg )
30+ except Exception :
31+ self .log .warning (f"Failed to show info: { msg } " )
4132
42- def _do ():
43- try :
44- ida_kernwin .info (msg )
45- except Exception :
46- self .log .warning (f"Failed to show info: { msg } " )
47-
48- self .safe_ui_exec (_do )
49-
50- def safe_refresh (self ) -> None :
51- """Safely refresh the disassembly view."""
52-
53- def _do ():
54- try :
55- ida_kernwin .refresh_idaview_anyway ()
56- except Exception :
57- self .log .warning ("Failed to refresh IDA view." )
5833
59- self .safe_ui_exec (_do )
34+ @execute_ui
35+ def refresh_disassembly_view (self ) -> None :
36+ try :
37+ ida_kernwin .refresh_idaview_anyway ()
38+ except Exception :
39+ self .log .warning ("Failed to refresh IDA view." )
6040
61- def safe_error (self , message : str ) -> None :
41+ @execute_ui
42+ def show_error_dialog (self , message : str ) -> None :
6243 """Show an error dialog safely."""
44+ try :
45+ self .factory .error_dialog (message = message ).open_modal ()
46+ except Exception :
47+ self .log .warning (f"Failed to show error dialog: { message } " )
6348
64- def _do ():
65- try :
66- self .factory .error_dialog (message = message ).open_modal ()
67- except Exception :
68- self .log .warning (f"Failed to show error dialog: { message } " )
69-
70- self .safe_ui_exec (_do )
7149
7250 # ======================================================
7351 # Authentication helper
0 commit comments