diff --git a/CHANGES b/CHANGES index 55ce1fd69..0890adf9d 100644 --- a/CHANGES +++ b/CHANGES @@ -73,6 +73,7 @@ Bugfixes: - OpenGL: Fix some shaders causing offset graphics - Qt: Fix game unpausing after frame advancing and refocusing - GB Timer: Fix sub-M-cycle DIV reset timing and edge triggering + - Core: Fix interrupting a thread while on the thread (fixes mgba.io/i/692) Misc: - SDL: Remove scancode key input - GBA Video: Clean up unused timers diff --git a/src/core/thread.c b/src/core/thread.c index 424260b7e..ed979d77a 100644 --- a/src/core/thread.c +++ b/src/core/thread.c @@ -401,11 +401,14 @@ void mCoreThreadInterruptFromThread(struct mCoreThread* threadContext) { MutexLock(&threadContext->stateMutex); ++threadContext->interruptDepth; if (threadContext->interruptDepth > 1 || !mCoreThreadIsActive(threadContext)) { + if (threadContext->state == THREAD_INTERRUPTING) { + threadContext->state = THREAD_INTERRUPTED; + } MutexUnlock(&threadContext->stateMutex); return; } threadContext->savedState = threadContext->state; - threadContext->state = THREAD_INTERRUPTING; + threadContext->state = THREAD_INTERRUPTED; ConditionWake(&threadContext->stateCond); MutexUnlock(&threadContext->stateMutex); }