acarapetis / shroudstone

Stormgate replay renamer (+ related tools)
GNU General Public License v3.0
7 stars 3 forks source link

Set config on start #4

Closed rojasreinold closed 6 months ago

rojasreinold commented 6 months ago

Right now there is an error on first run where you are unable to exit. To reproduce delete the whole shoudstone data directory and rerun shroudstone. The app will mostly start fine but the Exit button does nothing.

Error message on cli:

INFO     Cache files are from an incompatible version of shroudstone, deleting them.                                                                                         
INFO     Setting renaming config to use replays only - RIP stormgateworld API :(                                                                                             
INFO     Keep this console open - it will show progress information during renaming.                                                                                         
Exception in thread Thread-1 (_tray_icon_thread):
Traceback (most recent call last):
  File "/usr/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.12/threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "/home/rrojas/workspace/shroudstone/shroudstone/shroudstone/gui/app.py", line 123, in _tray_icon_thread
    @state.autorename.on_change
     ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rrojas/workspace/shroudstone/shroudstone/shroudstone/gui/app.py", line 34, in on_change
    self.trace_add("write", func)
  File "/usr/lib/python3.12/tkinter/__init__.py", line 459, in trace_add
    cbname = self._register(callback)
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/tkinter/__init__.py", line 443, in _register
    self._tk.createcommand(cbname, f)
RuntimeError: main thread is not in main loop

Fixed by saving the config on first load and choosing the current version as the last run (since there is no last run).

Also updated the readme with build steps.

acarapetis commented 6 months ago

Thanks for this. I can inconsistently reproduce the bug but your change doesn't seem to fix it for me - still get the error sometimes on first startup. Looking into it.

acarapetis commented 6 months ago

The real problem was that the tray icon thread was sometimes trying to interact with the Tk app before the Tk mainloop had started. I think I've fixed it, though the GUI code is still a mess... at some point it either needs a big cleanup/refactor or maybe just a rewrite in something like Qt that has tray icon support built-in.

Thanks for your contribution! :)