diff --git a/portprotonqt/app.py b/portprotonqt/app.py index e475b85..071955d 100644 --- a/portprotonqt/app.py +++ b/portprotonqt/app.py @@ -29,12 +29,10 @@ def main(): else: logger.error(f"Qt translations for {system_locale.name()} not found in {translations_path}") - # Парсинг аргументов командной строки args = parse_args() window = MainWindow() - # Обработка флага --fullscreen if args.fullscreen: logger.info("Launching in fullscreen mode due to --fullscreen flag") save_fullscreen_config(True) @@ -53,18 +51,19 @@ def main(): tray = None current_theme = read_theme_from_config() tray = SystemTray(app, current_theme) - tray.show_action.triggered.connect(window.show) - tray.hide_action.triggered.connect(window.hide) + # Ensure window is not None before connecting signals + if window: + tray.show_action.triggered.connect(window.show) + tray.hide_action.triggered.connect(window.hide) def cleanup_on_exit(): nonlocal tray, window - app.aboutToQuit.disconnect() # Disconnect to prevent further calls + app.aboutToQuit.disconnect() if tray: tray.cleanup() tray = None if window: window.close() - window = None app.quit() window.settings_saved.connect(recreate_tray) diff --git a/portprotonqt/tray.py b/portprotonqt/tray.py index 281c790..7c68fb3 100644 --- a/portprotonqt/tray.py +++ b/portprotonqt/tray.py @@ -35,14 +35,15 @@ class SystemTray: """Скрыть иконку трея""" if self.tray: self.tray.setVisible(False) - self.tray.setContextMenu(None) + if self.menu: + self.menu.deleteLater() + self.menu = None def cleanup(self): """Очистка ресурсов трея""" - self.hide_tray() + if self.tray: + self.tray.setVisible(False) + self.tray = None if self.menu: self.menu.deleteLater() self.menu = None - if self.tray: - self.tray.deleteLater() - self.tray = None