From 9a0561e9c2fe3ccade7a97477f49cfcff70ac34a Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sat, 14 Nov 2020 02:29:39 -0800 Subject: [PATCH] Core: Fix threading improperly setting paused state while interrupted --- CHANGES | 1 + src/core/thread.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index ae86ef9c3..61a399406 100644 --- a/CHANGES +++ b/CHANGES @@ -48,6 +48,7 @@ Other fixes: - All: Improve export headers (fixes mgba.io/i/1738) - CMake: Fix build with downstream minizip that exports incompatible symbols - Core: Ensure ELF regions can be written before trying + - Core: Fix threading improperly setting paused state while interrupted - Debugger: Don't skip undefined instructions when debugger attached - Debugger: Close trace log when done tracing - FFmpeg: Fix some small memory leaks diff --git a/src/core/thread.c b/src/core/thread.c index 4fbe6e95c..23eb00c53 100644 --- a/src/core/thread.c +++ b/src/core/thread.c @@ -568,7 +568,10 @@ void mCoreThreadTogglePause(struct mCoreThread* threadContext) { void mCoreThreadPauseFromThread(struct mCoreThread* threadContext) { bool frameOn = true; MutexLock(&threadContext->impl->stateMutex); - if (threadContext->impl->state == THREAD_RUNNING || (threadContext->impl->interruptDepth && threadContext->impl->savedState == THREAD_RUNNING)) { + if (threadContext->impl->interruptDepth && threadContext->impl->savedState == THREAD_RUNNING) { + threadContext->impl->savedState = THREAD_PAUSING; + frameOn = false; + } else if (threadContext->impl->state == THREAD_RUNNING) { threadContext->impl->state = THREAD_PAUSING; frameOn = false; }