Pidgeot / python-lnp

Cross-platform re-implementation of the Lazy Newb Pack launcher.
ISC License
64 stars 10 forks source link

macOS: SystemExit error message box when quitting from dock #182

Closed TV4Fun closed 1 year ago

TV4Fun commented 1 year ago

Using PyLNP 0.14b with macOS Monterey 12.6 (21G115). Right clicking on the dock and clicking quit, or going to quit from the Dwarf Fortress LNP menu, or typing cmd+Q produces this error message in a popup box before closing.

} {  File "python_lnp/launch.py", line 12, in <module>
} {  File "python_lnp/core/lnp.py", line 126, in __init__
} {  File "python_lnp/tkgui/tkgui.py", line 266, in start
} {  File "tkinter/__init__.py", line 1283, in mainloop
} {  File "tkinter/__init__.py", line 288, in _exit
} {SystemExit: 0
}
TV4Fun commented 1 year ago

This only seems to happen with the release build. I checked out the repo and used PyInstaller to build an app package, and that version doesn't do this. I don't know if this is a recent change of your, or if it's because I'm running on an M1 machine, the released version is an Intel binary, and the version PyInstaller made on my machine was an ARM binary.

Pidgeot commented 1 year ago

The build machine is completely unchanged, and there shouldn't have been any change to this part of the code when compared with 0.14a.

Unfortunately I don't really have any other machines to test it on, so it's quite difficult for me to guess as to why it's interpreting the exit request as an exception...

TV4Fun commented 1 year ago

I'm guessing it has to do with this line here. You have a try with an overly broad except clause that is catching the SystemExit exception and opening an error dialogue. That can probably be fixed by catching SystemExit separately and re-raising it, but I don't know why it's not happening on my checked out copy, and I'm not entirely comfortable submitting a fix for something I can't reproduce.

TV4Fun commented 1 year ago

@Pidgeot, what version of Python are you using when you build this? There was a bug in tkinter fixed about 10 years ago that may be responsible for this.

Pidgeot commented 1 year ago

It's using Python 3.7 on Mac, and I just checked that this change is indeed applied here.

But yeah, explicitly looking for SystemExit is probably the right choice, although why it's only the Mac version doing this is beyond me... let me prepare a fix and do a new set of builds.

Pidgeot commented 1 year ago

New build is up as 0.14c. Hopefully this'll take care of it.

TV4Fun commented 1 year ago

Yeah, it's fixed now. Thank you for the quick turnaround.