SDL: Properly clean up if a game doesn't launch

This commit is contained in:
Jeffrey Pfau 2015-01-25 03:37:15 -08:00
parent 19eaba3cdd
commit 0367a9db06
2 changed files with 11 additions and 5 deletions

View File

@ -29,6 +29,7 @@ Bugfixes:
- GBA Memory: Fix alignment of open bus 8- and 16-bit loads
- GBA Thread: Fix possible hang when loading an archive
- Perf: Fix crash when the GBA thread fails to start
- SDL: Properly clean up if a game doesn't launch
Misc:
- GBA Audio: Change internal audio sample buffer from 32-bit to 16-bit samples
- GBA Memory: Simplify memory API and use fixed bus width

View File

@ -105,12 +105,17 @@ int main(int argc, char** argv) {
GBASDLEventsLoadConfig(&renderer.events, &config.configTable); // TODO: Don't use this directly
context.overrides = &config.configTable;
GBAThreadStart(&context);
int didFail = 0;
if (GBAThreadStart(&context)) {
GBASDLRunloop(&context, &renderer);
GBAThreadJoin(&context);
} else {
didFail = 1;
printf("Could not run game. Are you sure the file exists and is a Game Boy Advance game?\n");
}
GBASDLRunloop(&context, &renderer);
GBAThreadJoin(&context);
if (GBAThreadHasCrashed(&context)) {
didFail = 1;
printf("The game crashed!\n");
}
freeArguments(&args);
@ -121,7 +126,7 @@ int main(int argc, char** argv) {
_GBASDLDeinit(&renderer);
return 0;
return didFail;
}
static bool _GBASDLInit(struct SDLSoftwareRenderer* renderer) {