Fix crashes when GBARR is not initialized

This commit is contained in:
Jeffrey Pfau 2014-07-23 00:09:14 -07:00
parent 3051143fa3
commit 94001b1133
1 changed files with 22 additions and 16 deletions

View File

@ -84,8 +84,10 @@ static void _GBASDLHandleKeypress(struct GBAThread* context, struct GBASDLEvents
return; return;
case SDLK_ESCAPE: case SDLK_ESCAPE:
GBAThreadInterrupt(context); GBAThreadInterrupt(context);
GBARRStopPlaying(context->gba->rr); if (context->gba->rr) {
GBARRStopRecording(context->gba->rr); GBARRStopPlaying(context->gba->rr);
GBARRStopRecording(context->gba->rr);
}
GBAThreadContinue(context); GBAThreadContinue(context);
return; return;
default: default:
@ -111,22 +113,26 @@ static void _GBASDLHandleKeypress(struct GBAThread* context, struct GBASDLEvents
GBAThreadReset(context); GBAThreadReset(context);
break; break;
case SDLK_t: case SDLK_t:
GBAThreadReset(context); if (context->gba->rr) {
GBAThreadInterrupt(context); GBAThreadReset(context);
GBARRContextCreate(context->gba); GBAThreadInterrupt(context);
GBARRSetStream(context->gba->rr, context->stateDir); GBARRContextCreate(context->gba);
GBARRStopPlaying(context->gba->rr); GBARRSetStream(context->gba->rr, context->stateDir);
GBARRStartRecording(context->gba->rr); GBARRStopPlaying(context->gba->rr);
GBAThreadContinue(context); GBARRStartRecording(context->gba->rr);
GBAThreadContinue(context);
}
break; break;
case SDLK_y: case SDLK_y:
GBAThreadReset(context); if (context->gba->rr) {
GBAThreadInterrupt(context); GBAThreadReset(context);
GBARRContextCreate(context->gba); GBAThreadInterrupt(context);
GBARRSetStream(context->gba->rr, context->stateDir); GBARRContextCreate(context->gba);
GBARRStopRecording(context->gba->rr); GBARRSetStream(context->gba->rr, context->stateDir);
GBARRStartPlaying(context->gba->rr, event->keysym.mod & KMOD_SHIFT); GBARRStopRecording(context->gba->rr);
GBAThreadContinue(context); GBARRStartPlaying(context->gba->rr, event->keysym.mod & KMOD_SHIFT);
GBAThreadContinue(context);
}
break; break;
default: default:
break; break;