From ad00b2f883a1df391aa02f09a45ddb3cb90591c3 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Fri, 18 Feb 2022 22:09:14 -0800 Subject: [PATCH] Core: Fix the runloop resuming after a game has crashed (fixes #2451) --- CHANGES | 1 + include/mgba/core/thread.h | 7 ++++--- src/core/thread.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 8e995f274..7624b8312 100644 --- a/CHANGES +++ b/CHANGES @@ -35,6 +35,7 @@ Emulation fixes: Other fixes: - 3DS: Ensure writes update file modification time (fixes mgba.io/i/2444) - Core: Don't attempt to restore rewind diffs past start of rewind + - Core: Fix the runloop resuming after a game has crashed (fixes mgba.io/i/2451) - FFmpeg: Fix crash when encoding audio with some containers - FFmpeg: Fix GIF recording (fixes mgba.io/i/2393) - GB: Fix temporary saves diff --git a/include/mgba/core/thread.h b/include/mgba/core/thread.h index 9f790cfe5..62605aa7f 100644 --- a/include/mgba/core/thread.h +++ b/include/mgba/core/thread.h @@ -54,14 +54,15 @@ enum mCoreThreadState { mTHREAD_INTERRUPTED, mTHREAD_PAUSED, - mTHREAD_MIN_WAITING = mTHREAD_INTERRUPTED, mTHREAD_CRASHED, - mTHREAD_MAX_WAITING = mTHREAD_PAUSED, mTHREAD_INTERRUPTING, mTHREAD_EXITING, - mTHREAD_SHUTDOWN + mTHREAD_SHUTDOWN, + + mTHREAD_MIN_WAITING = mTHREAD_INTERRUPTED, + mTHREAD_MAX_WAITING = mTHREAD_CRASHED }; enum mCoreThreadRequest { diff --git a/src/core/thread.c b/src/core/thread.c index de8a74987..1a9378a77 100644 --- a/src/core/thread.c +++ b/src/core/thread.c @@ -468,7 +468,7 @@ bool mCoreThreadIsActive(struct mCoreThread* threadContext) { if (!threadContext->impl) { return false; } - return threadContext->impl->state >= mTHREAD_RUNNING && threadContext->impl->state < mTHREAD_EXITING; + return threadContext->impl->state >= mTHREAD_RUNNING && threadContext->impl->state < mTHREAD_EXITING && threadContext->impl->state != mTHREAD_CRASHED; } void mCoreThreadInterrupt(struct mCoreThread* threadContext) {