Permalink
Browse files

Core: Fix interrupting a thread while on the thread (fixes #692)

  • Loading branch information...
endrift committed Jun 28, 2017
1 parent 23a346e commit dc5c59d4dbe157bb1c6fe1e00c0893815723a16b
Showing with 5 additions and 1 deletion.
  1. +1 −0 CHANGES
  2. +4 −1 src/core/thread.c
View
@@ -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
View
@@ -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);
}

0 comments on commit dc5c59d

Please sign in to comment.