ofApp destructor

I’ve had difficulty a few times because the destructor for my ofApp is never called when my app quits. The quitting setup looks quite complicated, with event handlers ultimately triggering a call to std::exit which instantly terminates the program.

The normal way to quit a C++ application in my experience is to allow program flow to reach the end of the main() function, which would happen by ofRunApp returning when it’s time to quit rather than cutting straight to std::exit. This would then let us destroy the ofApp instance and the appropriate destructors get called.

The main place where this has caused me problems is where I have a server with an open port which doesn’t get closed. Often after quitting I have to wait for the OS to close the port after around 30 seconds before I can rerun my app. Working with hardware drivers is another place where not destroying things properly can cause issues.

There is an exit() callback you can use for tidy up. But the way destructors automatically tidy stuff up is one of the nice things about C++ and it seems strange to not make the most of it. On the other hand, the current setup is quite complex so I’m sure it must have been done like that for a reason. Does anyone have any idea why? The issue has been raised before but I can’t find an explanation

Would there be any support for changing this to close the app in the more typical fashion?



I am curious as well? I posted a comment in an issue as well https://github.com/openframeworks/openFrameworks/issues/2603

Judging by that thread it looks like there is not problem with fixing it and submitting a pull request.