Savestates: Fix rare race

This commit is contained in:
Eladash 2024-04-13 22:43:25 +03:00 committed by Elad Ashkenazi
parent 6b906b9a9c
commit 51e1598e42
2 changed files with 28 additions and 6 deletions

View file

@ -3318,6 +3318,14 @@ void Emulator::Kill(bool allow_autoexit, bool savestate, savestate_stage* save_s
set_progress_message("Commiting File");
fs::file to_close_file;
{
auto reset = init_mtx->reset();
to_close_file = std::move(file.file);
reset.set_init();
}
to_close_file.close();
if (!file.commit() || !fs::get_stat(path, file_stat))
{
sys_log.error("Failed to write savestate to file! (path='%s', %s)", path, fs::g_tls_error);