State: Use RunOnCPUThread to invoke save state handlers
This ensures that the emulated state is only touched by the CPU thread
This commit is contained in:
parent
df45e714a3
commit
a25a4e0708
|
@ -204,16 +204,19 @@ void LoadFromBuffer(std::vector<u8>& buffer)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::RunAsCPUThread([&] {
|
Core::RunOnCPUThread(
|
||||||
|
[&] {
|
||||||
u8* ptr = &buffer[0];
|
u8* ptr = &buffer[0];
|
||||||
PointerWrap p(&ptr, PointerWrap::MODE_READ);
|
PointerWrap p(&ptr, PointerWrap::MODE_READ);
|
||||||
DoState(p);
|
DoState(p);
|
||||||
});
|
},
|
||||||
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveToBuffer(std::vector<u8>& buffer)
|
void SaveToBuffer(std::vector<u8>& buffer)
|
||||||
{
|
{
|
||||||
Core::RunAsCPUThread([&] {
|
Core::RunOnCPUThread(
|
||||||
|
[&] {
|
||||||
u8* ptr = nullptr;
|
u8* ptr = nullptr;
|
||||||
PointerWrap p(&ptr, PointerWrap::MODE_MEASURE);
|
PointerWrap p(&ptr, PointerWrap::MODE_MEASURE);
|
||||||
|
|
||||||
|
@ -224,7 +227,8 @@ void SaveToBuffer(std::vector<u8>& buffer)
|
||||||
ptr = &buffer[0];
|
ptr = &buffer[0];
|
||||||
p.SetMode(PointerWrap::MODE_WRITE);
|
p.SetMode(PointerWrap::MODE_WRITE);
|
||||||
DoState(p);
|
DoState(p);
|
||||||
});
|
},
|
||||||
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// return state number not in map
|
// return state number not in map
|
||||||
|
@ -381,7 +385,8 @@ static void CompressAndDumpState(CompressAndDumpState_args save_args)
|
||||||
|
|
||||||
void SaveAs(const std::string& filename, bool wait)
|
void SaveAs(const std::string& filename, bool wait)
|
||||||
{
|
{
|
||||||
Core::RunAsCPUThread([&] {
|
Core::RunOnCPUThread(
|
||||||
|
[&] {
|
||||||
// Measure the size of the buffer.
|
// Measure the size of the buffer.
|
||||||
u8* ptr = nullptr;
|
u8* ptr = nullptr;
|
||||||
PointerWrap p(&ptr, PointerWrap::MODE_MEASURE);
|
PointerWrap p(&ptr, PointerWrap::MODE_MEASURE);
|
||||||
|
@ -416,7 +421,8 @@ void SaveAs(const std::string& filename, bool wait)
|
||||||
// someone aborted the save by changing the mode?
|
// someone aborted the save by changing the mode?
|
||||||
Core::DisplayMessage("Unable to save: Internal DoState Error", 4000);
|
Core::DisplayMessage("Unable to save: Internal DoState Error", 4000);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReadHeader(const std::string& filename, StateHeader& header)
|
bool ReadHeader(const std::string& filename, StateHeader& header)
|
||||||
|
@ -525,7 +531,8 @@ void LoadAs(const std::string& filename)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::RunAsCPUThread([&] {
|
Core::RunOnCPUThread(
|
||||||
|
[&] {
|
||||||
g_loadDepth++;
|
g_loadDepth++;
|
||||||
|
|
||||||
// Save temp buffer for undo load state
|
// Save temp buffer for undo load state
|
||||||
|
@ -582,7 +589,8 @@ void LoadAs(const std::string& filename)
|
||||||
s_on_after_load_callback();
|
s_on_after_load_callback();
|
||||||
|
|
||||||
g_loadDepth--;
|
g_loadDepth--;
|
||||||
});
|
},
|
||||||
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetOnAfterLoadCallback(AfterLoadCallbackFunc callback)
|
void SetOnAfterLoadCallback(AfterLoadCallbackFunc callback)
|
||||||
|
|
Loading…
Reference in New Issue