From d29e7827893c8a3c5d25b948db14f4f988d063ae Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sat, 28 Jan 2023 22:39:00 -0800 Subject: [PATCH] Core: Allow sending thread requests to a crashed core (fixes #2785) --- CHANGES | 1 + src/core/thread.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 6b26e6bc8..ad269f26b 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,7 @@ Emulation fixes: - GBA Memory: Make VRAM access stalls only apply to BG RAM Other fixes: + - Core: Allow sending thread requests to a crashed core (fixes mgba.io/i/2785) - Qt: Fix crash when attempting to use OpenGL 2.1 to 3.1 (fixes mgba.io/i/2794) - Qt: Disable sync while running scripts from main thread (fixes mgba.io/i/2738) Misc: diff --git a/src/core/thread.c b/src/core/thread.c index 7101b5a54..510e45f98 100644 --- a/src/core/thread.c +++ b/src/core/thread.c @@ -58,8 +58,19 @@ static void _waitOnInterrupt(struct mCoreThreadInternal* threadContext) { } static void _pokeRequest(struct mCoreThreadInternal* threadContext) { - if (threadContext->state == mTHREAD_RUNNING || threadContext->state == mTHREAD_PAUSED) { + switch (threadContext->state) { + case mTHREAD_RUNNING: + case mTHREAD_PAUSED: + case mTHREAD_CRASHED: threadContext->state = mTHREAD_REQUEST; + break; + case mTHREAD_INITIALIZED: + case mTHREAD_REQUEST: + case mTHREAD_INTERRUPTED: + case mTHREAD_INTERRUPTING: + case mTHREAD_EXITING: + case mTHREAD_SHUTDOWN: + break; } }