fixed situations where app doesnt shut down without crash

- when bot is closed while engine is running
- when start is pressed when the game is minimized, then app is closed
This commit is contained in:
Adam Saudagar 2020-10-18 06:20:25 +05:30
parent db5299004b
commit 80c2a5e900
2 changed files with 8 additions and 2 deletions

View File

@ -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")

View File

@ -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