diff --git a/synodic_client/application/screen/tool_update_controller.py b/synodic_client/application/screen/tool_update_controller.py index d8c207c..2f91f28 100644 --- a/synodic_client/application/screen/tool_update_controller.py +++ b/synodic_client/application/screen/tool_update_controller.py @@ -389,5 +389,3 @@ def _on_package_remove_finished( tools_view.set_package_removing(plugin_name, package_name, False) tools_view._updates_checked = False tools_view.refresh() - - self._window.show() diff --git a/tool/pyinstaller/rthook_no_console.py b/tool/pyinstaller/rthook_no_console.py index 3f08fa1..e49d4fc 100644 --- a/tool/pyinstaller/rthook_no_console.py +++ b/tool/pyinstaller/rthook_no_console.py @@ -3,8 +3,14 @@ When the application is built as a windowed executable (``console=False``), every ``subprocess.Popen`` call that launches a console program (pip, pipx, uv, winget, etc.) would briefly flash a visible console window. This hook -merges ``CREATE_NO_WINDOW`` into *creationflags* for every call, suppressing -those flashes while preserving any flags the caller already set. +patches every ``subprocess.Popen`` call with two complementary mitigations: + +* ``CREATE_NO_WINDOW`` in *creationflags* — prevents Windows from allocating + a new console for the child process. +* ``STARTUPINFO`` with ``STARTF_USESHOWWINDOW`` and ``wShowWindow=SW_HIDE`` + — tells Windows to pass ``SW_HIDE`` as the initial ``nCmdShow`` to the + child, suppressing the brief window flash that some GUI-subsystem tools + (e.g. ``winget.exe``) produce even without a console. Placed as a runtime hook so the patch is active before any application or library code spawns subprocesses. @@ -15,10 +21,22 @@ from typing import Any if sys.platform == 'win32': + import subprocess as _sp + + _SW_HIDE = 0 + _STARTF_USESHOWWINDOW = _sp.STARTF_USESHOWWINDOW + _CREATE_NO_WINDOW = _sp.CREATE_NO_WINDOW + _original_init = subprocess.Popen.__init__ def _patched_init(self: subprocess.Popen, *args: Any, **kwargs: Any) -> None: - kwargs['creationflags'] = kwargs.get('creationflags', 0) | subprocess.CREATE_NO_WINDOW + kwargs['creationflags'] = kwargs.get('creationflags', 0) | _CREATE_NO_WINDOW + + startupinfo = kwargs.get('startupinfo') or _sp.STARTUPINFO() + startupinfo.dwFlags |= _STARTF_USESHOWWINDOW + startupinfo.wShowWindow = _SW_HIDE + kwargs['startupinfo'] = startupinfo + _original_init(self, *args, **kwargs) subprocess.Popen.__init__ = _patched_init