openframeworks/openFrameworks — Issue #770: ofExitCallback() does cleanup before notifying the running app
Author: timscaffidi
Created: 2011-10-10 06:07:10+00:00
State: open

in ofAppRunner.cpp, ofExitCallback() calls ofNotifyExit() last, after closing the sound stream and cleaning up free image. This created a problem for me when I had some code in my testApp::exit() function which was trying to use ofSaveImage(), and getting a segfault beacuse freeImage is no longer loaded.

By moving ofNotifyExit() to the top of the function, the problem is solved. I'm not sure if this introduces other problems, but I checked with the debugger and everything else does get called after the testApp::exit() function returns, so it should be okay.