MacOS fix for closeWindow() in fullscreen

Hi there,

Firstly, I really enjoy Cinder! I have been using it for many years, and decided to update all my 7 apps to 64-bit under v0.9.2. It took awhile to get everything updated, and I thought one discovery might help others, and/or perhaps it will be fixed in the next release.

Take almost any samples project, build and run. Here I use SurfaceBasic.

Click the green dot to go into fullscreen mode. Now click the red dot to close the window (and quit the app). Xcode goes into lldb debugger and provides a traceback showing EXC_BAD_ACCESS in the ExecuteLaunch() function.

Here is the screen with the traceback:

For some reason, clicking the red dot when not in fullscreen mode, does not crash.

To fix this, add this line to the setup() function to catch the close signal:

getWindow()->getSignalClose().connect( std::bind( &yourApp::windowClosed, this ) );

Then make a function to handle windowClosed signals, calling a cleanup() function (if you need to free any other resources, usually none):

void windowClosed(); // handle window-close event
void cleanup() override ; // override the cleanup

// ------------
void yourApp::windowClosed()
console() << “#OK window closed, exiting” << std::endl;

// ------------
void jjlgImageHFApp::cleanup()
console() << “#OK cleanup” << std::endl;

Now repeat the test, and you should see this in the console window:

#OK window closed, exiting
#OK cleanup

If instead you type command-Q, it only calls cleanup().

Now I can click the red dot or type command-Q with aplomb.