diff --git a/fishy/engine/common/window.py b/fishy/engine/common/window.py index 5583f9e..e28310d 100644 --- a/fishy/engine/common/window.py +++ b/fishy/engine/common/window.py @@ -29,7 +29,8 @@ class WindowClient: WindowClient.clients.append(self) def destory(self): - WindowClient.clients.remove(self) + if self in WindowClient.clients: + WindowClient.clients.remove(self) if len(WindowClient.clients) == 0: window_server.stop() logging.info("window server stopped") diff --git a/fishy/gui/main_gui.py b/fishy/gui/main_gui.py index efd1222..3db6f5f 100644 --- a/fishy/gui/main_gui.py +++ b/fishy/gui/main_gui.py @@ -24,6 +24,7 @@ def _apply_theme(gui: 'GUI'): gui._console["fg"] = "#ffffff" if dark else "#000000" +# noinspection PyProtectedMember def _create(gui: 'GUI'): engines = gui.engines @@ -105,8 +106,12 @@ def _create(gui: 'GUI'): hotkey.set_hotkey(Key.F9, gui.funcs.start_engine) + # noinspection PyProtectedMember def set_destroy(): - gui._destroyed = True + if gui._bot_running: + logging.info("Turn off the bot engine first") + else: + gui._destroyed = True gui._root.protocol("WM_DELETE_WINDOW", set_destroy) gui._destroyed = False