py5coding / py5generator

Meta-programming project that creates the py5 library code.
https://py5coding.org/
GNU General Public License v3.0
52 stars 13 forks source link

On OSX, the Sketch window does not close after a call to `exit_sketch()` if the Sketch stopped because of an error #7

Closed hx2A closed 3 years ago

hx2A commented 3 years ago

On OSX, the Sketch window does not close after a call to exit_sketch() if the Sketch stopped because of an error. After calling exit_sketch(), the window is in some half dead state and cannot be closed by hitting the red button in the upper left corner. The python process hangs and needs to be killed.

On Linux, the window will close properly when exit_sketch() is called.

Steps to reproduce:

  1. Run this Sketch:
    def draw():
    py5.rect("error")
  2. Call exit_sketch():
    py5.exit_sketch()
  3. The window is still open but the 3 colored control buttons are now gray. The window cannot be closed without killing the Python process.

Workaround: Don't call exit_sketch() after an error. Manually close the window with the red button in the upper left corner.

hx2A commented 3 years ago

(disregard 713c8e2)

This bug only applies when an OpenGL renderer is used. Latest commit improves this so that at least the user can get rid of the window using the red circle button in the upper left corner. The window can come back by clicking on the dock icon enough times though. Still, this is an improvement because the Python process no longer hangs and does not need to be killed.

hx2A commented 3 years ago

Finally fixed for real by re-engineering the shutdown code. While fixing this I discovered that on OSX, Sketches that had called no_loop() also cannot be shutdown properly. Fixed that also. Also somehow I magically repaired the ability to close the window by hitting the ESC key.

See https://github.com/hx2A/py5generator/commit/3181e6318bd1301e1b29352382ce0903417a3c88 and https://github.com/hx2A/py5generator/commit/d591588347df57dd0c286e40d76c5aaee15ac4e1 for code relevant to the fix.