From 3f0d259bf0fd7f800f6b3c39851d3d18603290d1 Mon Sep 17 00:00:00 2001 From: Boris Yumankulov Date: Wed, 25 Jun 2025 10:56:46 +0500 Subject: [PATCH] fix(toggleGame): enable PortProton game launch by removing premature return and setting proper process tracking Signed-off-by: Boris Yumankulov --- portprotonqt/main_window.py | 53 +++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/portprotonqt/main_window.py b/portprotonqt/main_window.py index ce8a7a8..ff93023 100644 --- a/portprotonqt/main_window.py +++ b/portprotonqt/main_window.py @@ -2072,41 +2072,36 @@ class MainWindow(QMainWindow): exe_name = os.path.splitext(current_exe)[0] env_vars = os.environ.copy() - # Delay disabling gamepad handling to allow rumble to complete - if hasattr(self, 'input_manager'): - QTimer.singleShot(200, self.input_manager.disable_gamepad_handling) - if entry_exec_split[0] == "env" and len(entry_exec_split) > 1 and 'data/scripts/start.sh' in entry_exec_split[1]: env_vars['START_FROM_STEAM'] = '1' elif entry_exec_split[0] == "flatpak": env_vars['START_FROM_STEAM'] = '1' - return - # Запускаем игру - self.current_running_button = update_button - self.target_exe = current_exe - exe_name = os.path.splitext(current_exe)[0] - env_vars = os.environ.copy() - env_vars['START_FROM_STEAM'] = '1' - try: - process = subprocess.Popen(entry_exec_split, env=env_vars, shell=False, preexec_fn=os.setsid) - self.game_processes.append(process) - save_last_launch(exe_name, datetime.now()) - if update_button: - update_button.setText(_("Launching")) - icon = self.theme_manager.get_icon("stop") - if isinstance(icon, str): - icon = QIcon(icon) - elif icon is None: - icon = QIcon() - update_button.setIcon(icon) + # Delay disabling gamepad handling to allow rumble to complete + if hasattr(self, 'input_manager'): + QTimer.singleShot(200, self.input_manager.disable_gamepad_handling) + + # Запускаем игру + try: + process = subprocess.Popen(entry_exec_split, env=env_vars, shell=False, preexec_fn=os.setsid) + self.game_processes.append(process) + save_last_launch(exe_name, datetime.now()) + if update_button: + update_button.setText(_("Launching")) + icon = self.theme_manager.get_icon("stop") + if isinstance(icon, str): + icon = QIcon(icon) + elif icon is None: + icon = QIcon() + update_button.setIcon(icon) + + self.checkProcessTimer = QTimer(self) + self.checkProcessTimer.timeout.connect(self.checkTargetExe) + self.checkProcessTimer.start(500) + except Exception as e: + logger.error(f"Failed to launch game {exe_name}: {e}") + QMessageBox.warning(self, _("Error"), _("Failed to launch game: {0}").format(str(e))) - self.checkProcessTimer = QTimer(self) - self.checkProcessTimer.timeout.connect(self.checkTargetExe) - self.checkProcessTimer.start(500) - except Exception as e: - logger.error(f"Failed to launch game {exe_name}: {e}") - QMessageBox.warning(self, _("Error"), _("Failed to launch game: {0}").format(str(e))) def closeEvent(self, event): """Завершает все дочерние процессы и сохраняет настройки при закрытии окна."""