Refactor windowed mode and subprocess handling

Removed redundant windowed mode setup from main.py and simplified subprocess creation flags logic across core and GUI modules. Centralized subprocess creation flags usage, eliminated custom run_subprocess_hidden wrapper, and improved logging handler setup for better compatibility with windowed applications.
This commit is contained in:
Your Name
2025-08-27 23:00:08 +03:00
parent b23be4335e
commit f390d23f54
5 changed files with 35 additions and 169 deletions
+1 -16
View File
@@ -1,6 +1,5 @@
import json
import subprocess
import sys
import threading
import webbrowser
from pathlib import Path
@@ -1736,21 +1735,7 @@ class YTSageApp(QMainWindow, FormatTableMixin, VideoInfoMixin): # Inherit from
# Execute command with hidden console window on Windows
# Extra logic moved to src\utils\ytsage_constants.py
creation_flags = SUBPROCESS_CREATIONFLAGS
if getattr(sys, 'frozen', False):
# Running as compiled executable - use additional flags to prevent console flicker
creation_flags |= subprocess.CREATE_NEW_PROCESS_GROUP | subprocess.DETACHED_PROCESS
result = subprocess.run(
cmd,
capture_output=True,
text=True,
timeout=60,
creationflags=creation_flags,
stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
result = subprocess.run(cmd, capture_output=True, text=True, timeout=60, creationflags=SUBPROCESS_CREATIONFLAGS)
if result.returncode != 0:
raise Exception(f"yt-dlp failed: {result.stderr}")