PINE: fix save state regression introduced during the switch to Qt

Ensure thread safety when loading/saving state
This commit is contained in:
GovanifY 2024-01-25 09:37:15 +01:00 committed by Connor McLaughlin
parent be208df11b
commit 325e219bb1
1 changed files with 3 additions and 2 deletions

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: LGPL-3.0+
#include "Common.h"
#include "Host.h"
#include "Memory.h"
#include "Elfheader.h"
#include "PINE.h"
@ -623,7 +624,7 @@ PINEServer::IPCBuffer PINEServer::ParseCommand(std::span<u8> buf, std::vector<u8
goto error;
if (!SafetyChecks(buf_cnt, 1, ret_cnt, 0, buf_size)) [[unlikely]]
goto error;
VMManager::SaveStateToSlot(FromSpan<u8>(buf, buf_cnt));
Host::RunOnCPUThread([slot = FromSpan<u8>(buf, buf_cnt)] { VMManager::SaveStateToSlot(slot); });
buf_cnt += 1;
break;
}
@ -633,7 +634,7 @@ PINEServer::IPCBuffer PINEServer::ParseCommand(std::span<u8> buf, std::vector<u8
goto error;
if (!SafetyChecks(buf_cnt, 1, ret_cnt, 0, buf_size)) [[unlikely]]
goto error;
VMManager::LoadStateFromSlot(FromSpan<u8>(buf, buf_cnt));
Host::RunOnCPUThread([slot = FromSpan<u8>(buf, buf_cnt)] { VMManager::LoadStateFromSlot(slot); });
buf_cnt += 1;
break;
}