From 7369169331d4f4744be4560aac8ea8ac7b6b8bb3 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 4 Jan 2025 16:14:28 +0100 Subject: [PATCH] Disable continuous mode if a savestate is not possible --- rpcs3/Emu/System.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index ee0c8204c1..ced67c8a7e 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -3063,6 +3063,22 @@ void Emulator::Kill(bool allow_autoexit, bool savestate, savestate_stage* save_s *pause_thread = make_ptr(new named_thread("Savestate Prepare Thread"sv, [pause_thread, allow_autoexit, this]() mutable { + struct scoped_success_guard + { + bool save_state_success = false; + ~scoped_success_guard() + { + if (!save_state_success) + { + // Reset continuous mode on savestate error + Emu.SetContinuousMode(false); + + // Reset after_kill_callback (which is usually used for Emu.Restart in combination with savestates) + Emu.after_kill_callback = nullptr; + } + } + } success_guard {}; + std::vector>, u32>> paused_spus; if (!try_lock_spu_threads_in_a_state_compatible_with_savestates(false, &paused_spus)) @@ -3133,6 +3149,8 @@ void Emulator::Kill(bool allow_autoexit, bool savestate, savestate_stage* save_s return; } + success_guard.save_state_success = true; + CallFromMainThread([allow_autoexit, this, paused_spus]() { savestate_stage stage{};