Core: Add existing state check for rewind

This commit is contained in:
Jeffrey Pfau 2016-10-26 21:41:44 -07:00
parent 26a62cce64
commit e430e55149
2 changed files with 9 additions and 0 deletions

View File

@ -30,6 +30,7 @@ Misc:
- GB, GBA: Prevent loading null ROMs
- VFS: Allow truncating memory chunk VFiles
- Debugger: Modularize CLI debugger
- Core: Clean up some thread state checks
0.5.1: (2016-10-05)
Bugfixes:

View File

@ -478,6 +478,14 @@ void mCoreThreadPauseFromThread(struct mCoreThread* threadContext) {
void mCoreThreadSetRewinding(struct mCoreThread* threadContext, bool rewinding) {
MutexLock(&threadContext->stateMutex);
if (rewinding && (threadContext->state == THREAD_REWINDING || (threadContext->state == THREAD_INTERRUPTING && threadContext->savedState == THREAD_REWINDING))) {
MutexUnlock(&threadContext->stateMutex);
return;
}
if (!rewinding && (threadContext->state == THREAD_RUNNING || (threadContext->state == THREAD_INTERRUPTING && threadContext->savedState == THREAD_RUNNING))) {
MutexUnlock(&threadContext->stateMutex);
return;
}
_waitOnInterrupt(threadContext);
if (rewinding && threadContext->state == THREAD_RUNNING) {
threadContext->state = THREAD_REWINDING;