2222import shutil
2323from typing import Any , Optional
2424
25- from PySide6 .QtCore import QProcess , QObject , Signal , Slot , QMetaObject , Qt
25+ from PySide6 .QtCore import QProcess , QObject , QTimer , Qt
2626from PySide6 .QtWidgets import QMessageBox
2727
2828from pycompiler_ark .Core .SysDependencyManager import SysDependencyManager
3232class SysDependencyUI (SysDependencyManager ):
3333 """
3434 GUI extension of SysDependencyManager.
35- Proxies GUI calls to the main thread to avoid segfaults.
35+ Proxies GUI calls to the main thread to avoid segfaults and PySide6 signature errors .
3636 """
3737
3838 def __init__ (self , parent_widget = None ):
@@ -54,7 +54,7 @@ def _ui_tr(self, fr: str, en: str) -> str:
5454
5555 def _ui_register_task (self , proc : QProcess , dlg : Optional [Any ], label_fr : str , label_en : str ) -> None :
5656 if self .parent_widget is None : return
57- # Simple task registration is generally thread-safe if it's just a list
57+ # Task registration is generally thread-safe for list operations
5858 try :
5959 tasks = getattr (self .parent_widget , "_sysdep_tasks" , [])
6060 tasks .append ({"process" : proc , "dialog" : dlg , "label_fr" : label_fr , "label_en" : label_en })
@@ -71,9 +71,13 @@ def _ui_unregister_task(self, proc: QProcess) -> None:
7171 pass
7272
7373 def _invoke_gui (self , method : callable , * args ):
74- """Invoke a method on the GUI thread."""
74+ """
75+ Invoke a method on the GUI thread using QTimer.singleShot.
76+ This is the most compatible way to pass a lambda/callable across threads in PySide6.
77+ """
7578 if self .parent_widget :
76- QMetaObject .invokeMethod (self .parent_widget , lambda : method (* args ), Qt .QueuedConnection )
79+ # QTimer.singleShot(0, context, callable) ensures execution in context's thread
80+ QTimer .singleShot (0 , self .parent_widget , lambda : method (* args ))
7781 else :
7882 method (* args )
7983
@@ -84,14 +88,20 @@ def _show():
8488
8589 def _show_progress (self , title_fr : str , title_en : str , msg_fr : str , msg_en : str ):
8690 def _create ():
91+ # Close existing one if any
92+ if self ._progress_dlg :
93+ try : self ._progress_dlg .close ()
94+ except Exception : pass
95+
8796 self ._progress_dlg = ProgressDialog (self .tr (title_fr , title_en ), self .parent_widget )
8897 self ._progress_dlg .set_message (self .tr (msg_fr , msg_en ))
8998 self ._progress_dlg .show ()
9099 self ._invoke_gui (_create )
91100
92101 def _update_progress (self , msg : str ):
93102 def _upd ():
94- if self ._progress_dlg : self ._progress_dlg .set_message (msg )
103+ if self ._progress_dlg :
104+ self ._progress_dlg .set_message (msg )
95105 self ._invoke_gui (_upd )
96106
97107 def _close_progress (self ):
0 commit comments