clintbellanger / flare

Free Libre Action Roleplaying Engine
http://clintbellanger.net/rpg/
GNU General Public License v3.0
166 stars 41 forks source link

Improve error handling #977

Closed igorko closed 11 years ago

igorko commented 11 years ago

Discovered while trying to load GameStateLoad screen on Polymorphable with Flare savegame in the list. Also added exit(1) where needed to really terminate app correctly.

igorko commented 11 years ago

oops. It doesn't build.

stefanbeller commented 11 years ago

In http://sdl.beuc.net/sdl.wiki/SDL_Quit they say we could also use atexit(SDL_Quit); Not sure what's the best approach though.

Note: While using "atexit" may be be fine for small programs, more advanced users should shut down SDL in their own cleanup code. Moreover, using "atexit" in a library is a sure way to crash dynamically loaded code.

igorko commented 11 years ago

No idea why that exit(1) is blamed by g++, but we can leave without it ;)

ghost commented 11 years ago

There's a member variable named "exit" in MenuManager. You can probably use something like "std::exit(1)" to avoid the name collision.

stefanbeller commented 11 years ago

Another idea would be to put the exit (or abort function?) together with a previous SDL_Quit into a function, as the sequence

SDL_Quit()
exit(1);

happens to appear quite often now.

clintbellanger commented 11 years ago

Consider this a short-term fix. During Beta we will have better clean-up code that will attempt to free memory properly.