From ea016382f29af94c12d1dc95317aa174d98f9660 Mon Sep 17 00:00:00 2001 From: brian218 Date: Tue, 25 Jul 2023 12:26:56 +0800 Subject: [PATCH] Fixed Emu.Restart(graceful=false) no longer worked after #14038 --- rpcs3/Emu/System.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index c005e67371..e1343db436 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -2977,6 +2977,21 @@ void Emulator::Kill(bool allow_autoexit, bool savestate) game_boot_result Emulator::Restart(bool graceful) { + if (m_state == system_state::stopping) + { + // Emulation stop is in progress + return game_boot_result::still_running; + } + + Emu.after_kill_callback = [this] + { + // Reload with prior configs. + if (const auto error = Load(m_title_id); error != game_boot_result::no_errors) + { + sys_log.error("Restart failed: %s", error); + } + }; + if (!IsStopped()) { auto save_args = std::make_tuple(argv, envp, data, disc, klic, hdd1, m_config_mode, m_config_mode); @@ -2988,12 +3003,10 @@ game_boot_result Emulator::Restart(bool graceful) std::tie(argv, envp, data, disc, klic, hdd1, m_config_mode, m_config_mode) = std::move(save_args); } - - // Reload with prior configs. - if (const auto error = Load(m_title_id); error != game_boot_result::no_errors) + else { - sys_log.error("Restart failed: %s", error); - return error; + // Execute and empty the callback + ::as_rvalue(std::move(Emu.after_kill_callback))(); } return game_boot_result::no_errors;