all repos — mgba @ 94001b113311cad1cce263f14afa2334a5ba4249

mGBA Game Boy Advance Emulator

Fix crashes when GBARR is not initialized
Jeffrey Pfau jeffrey@endrift.com
Wed, 23 Jul 2014 00:09:14 -0700
commit

94001b113311cad1cce263f14afa2334a5ba4249

parent

3051143fa3a1a458ac6c15af56ab3cd07ddc5e15

1 files changed, 22 insertions(+), 16 deletions(-)

jump to
M src/platform/sdl/sdl-events.csrc/platform/sdl/sdl-events.c

@@ -84,8 +84,10 @@ GBAThreadContinue(context);

return; case SDLK_ESCAPE: GBAThreadInterrupt(context); - GBARRStopPlaying(context->gba->rr); - GBARRStopRecording(context->gba->rr); + if (context->gba->rr) { + GBARRStopPlaying(context->gba->rr); + GBARRStopRecording(context->gba->rr); + } GBAThreadContinue(context); return; default:

@@ -111,22 +113,26 @@ case SDLK_r:

GBAThreadReset(context); break; case SDLK_t: - GBAThreadReset(context); - GBAThreadInterrupt(context); - GBARRContextCreate(context->gba); - GBARRSetStream(context->gba->rr, context->stateDir); - GBARRStopPlaying(context->gba->rr); - GBARRStartRecording(context->gba->rr); - GBAThreadContinue(context); + if (context->gba->rr) { + GBAThreadReset(context); + GBAThreadInterrupt(context); + GBARRContextCreate(context->gba); + GBARRSetStream(context->gba->rr, context->stateDir); + GBARRStopPlaying(context->gba->rr); + GBARRStartRecording(context->gba->rr); + GBAThreadContinue(context); + } break; case SDLK_y: - GBAThreadReset(context); - GBAThreadInterrupt(context); - GBARRContextCreate(context->gba); - GBARRSetStream(context->gba->rr, context->stateDir); - GBARRStopRecording(context->gba->rr); - GBARRStartPlaying(context->gba->rr, event->keysym.mod & KMOD_SHIFT); - GBAThreadContinue(context); + if (context->gba->rr) { + GBAThreadReset(context); + GBAThreadInterrupt(context); + GBARRContextCreate(context->gba); + GBARRSetStream(context->gba->rr, context->stateDir); + GBARRStopRecording(context->gba->rr); + GBARRStartPlaying(context->gba->rr, event->keysym.mod & KMOD_SHIFT); + GBAThreadContinue(context); + } break; default: break;