Fix an issue with settings being saved too early

This commit is contained in:
DevilXD committed 2022-04-10 16:02:59 +02:00
1 parent 3bccbc45c3
commit 2f452ca045
2 files changed
+6 -3

No files matched your search

+4
View File
@@ -177,6 +177,10 @@ if not client.gui.close_requested:
"\nApplication Terminated.\nClose the window to exit the application." "\nApplication Terminated.\nClose the window to exit the application."
) )
loop.run_until_complete(client.gui.wait_until_closed()) loop.run_until_complete(client.gui.wait_until_closed())
# save settings
# NOTE: we have to do it after wait_until_closed,
# because the user can alter settings between shutdown and closing the window
client.settings.save()
client.gui.stop() client.gui.stop()
client.gui.close_window() client.gui.close_window()
loop.run_until_complete(loop.shutdown_asyncgens()) loop.run_until_complete(loop.shutdown_asyncgens())
+2 -3
View File
@@ -102,9 +102,8 @@ class Twitch:
session, self._session = self._session, None session, self._session = self._session, None
await session.close() await session.close()
await self.websocket.stop() await self.websocket.stop()
# save other important files # save image cache
self.settings.save() # settings self.gui.save()
self.gui.save() # image cache
# wait at least half a second + whatever it takes to complete the closing # wait at least half a second + whatever it takes to complete the closing
# this allows aiohttp to safely close the session # this allows aiohttp to safely close the session
await asyncio.sleep(start_time + 0.5 - time()) await asyncio.sleep(start_time + 0.5 - time())