libretiny-eu / ltchiptool

Universal, easy-to-use GUI flashing/dumping tool for BK7231, RTL8710B and RTL8720C.
MIT License
67 stars 4 forks source link

[gui] Fix error when exiting on MacOS #4

Closed alufers closed 1 year ago

alufers commented 1 year ago

For some reason on MacOS the OnShow method of the LogPanel is called when exiting the application. This causes the panel to try to print the delayed_lines again and throw an error.

A check whether delayed_lines is None has been added.

Screenshot of the error:

image

Btw here is the full traceback of the second call to OnShow:

 File "<string>", line 1, in <module>
  File "/Users/alufers/Projects/Contrib/ltchiptool/ltchiptool/__init__.py", line 23, in cli
    cli()
  File "/Users/alufers/Projects/Contrib/ltchiptool/ltchiptool/__main__.py", line 97, in cli
    cli_entrypoint()
  File "/Users/alufers/Library/Caches/pypoetry/virtualenvs/ltchiptool-XyYUebX7-py3.10/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/alufers/Library/Caches/pypoetry/virtualenvs/ltchiptool-XyYUebX7-py3.10/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/alufers/Library/Caches/pypoetry/virtualenvs/ltchiptool-XyYUebX7-py3.10/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/alufers/Library/Caches/pypoetry/virtualenvs/ltchiptool-XyYUebX7-py3.10/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/alufers/Library/Caches/pypoetry/virtualenvs/ltchiptool-XyYUebX7-py3.10/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/alufers/Projects/Contrib/ltchiptool/ltchiptool/util/../../ltchiptool/gui/__main__.py", line 47, in cli
    gui_entrypoint(*args, **kwargs)
  File "/Users/alufers/Projects/Contrib/ltchiptool/ltchiptool/util/../../ltchiptool/gui/__main__.py", line 30, in gui_entrypoint
    app.MainLoop()
  File "/Users/alufers/Library/Caches/pypoetry/virtualenvs/ltchiptool-XyYUebX7-py3.10/lib/python3.10/site-packages/wx/core.py", line 2262, in MainLoop
    rv = wx.PyApp.MainLoop(self)
  File "/Users/alufers/Projects/Contrib/ltchiptool/ltchiptool/gui/main.py", line 167, in OnClose
    self.Destroy()
  File "/Users/alufers/Projects/Contrib/ltchiptool/ltchiptool/gui/main.py", line 152, in OnShow
    panel.OnShow()
  File "/Users/alufers/Projects/Contrib/ltchiptool/ltchiptool/gui/panels/log.py", line 187, in OnShow
    traceback.print_stack()
I have no idea why self.Destroy() calls OnShow, but it does...
kuba2k2 commented 1 year ago

Thanks for the fix! I have no idea why I didn't add the check in the first place... I've seen this error message at the beginning of logs (on screenshots made by other people, on Windows) but had no idea what could cause this (and the program worked fine anyway). Strangely, it has never occurred to me on my machine.