Skip to content

Commit

Permalink
Debugger: Lua - Keep the first non-zero value when emu.stop + prevent…
Browse files Browse the repository at this point in the history
… crash when called multiple times
  • Loading branch information
SourMesen committed Apr 7, 2024
1 parent a015fa8 commit 852f92f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Core/Shared/Emulator.cpp
Expand Up @@ -1063,8 +1063,14 @@ bool Emulator::IsEmulationThread()

void Emulator::SetStopCode(int32_t stopCode)
{
if(_stopCode != 0) {
//If a non-0 code was already set, keep the previous value
return;
}

_stopCode = stopCode;
if(!_stopFlag) {
if(!_stopFlag && !_stopRequested) {
_stopRequested = true;
thread stopEmuTask([this]() {
Stop(true);
});
Expand Down
1 change: 1 addition & 0 deletions Core/Shared/Emulator.h
Expand Up @@ -116,6 +116,7 @@ class Emulator

uint32_t _autoSaveStateFrameCounter = 0;
int32_t _stopCode = 0;
bool _stopRequested = false;

void WaitForLock();
void WaitForPauseEnd();
Expand Down

0 comments on commit 852f92f

Please sign in to comment.