From 9256a0277f0eb4d893a43b1964ed4850e61a2022 Mon Sep 17 00:00:00 2001 From: schm1dtmac Date: Mon, 11 May 2026 17:00:14 +0100 Subject: [PATCH] Fix restart-loops upon restart-then-quit (std::exchange one-liner courtesy of Elad <18193363+elad335@users.noreply.github.com>) --- rpcs3/Emu/System.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 29016a408a..1f6f5090c4 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -4068,8 +4068,7 @@ void Emulator::Kill(bool allow_autoexit, bool savestate, savestate_stage* save_s if (after_kill_callback) { // Make after_kill_callback empty before call - const auto callback = std::move(after_kill_callback); - callback(); + std::exchange(after_kill_callback, nullptr)(); } }); })); @@ -4125,7 +4124,7 @@ game_boot_result Emulator::Restart(bool graceful, bool reset_path) else { // Execute and empty the callback - ::as_rvalue(std::move(Emu.after_kill_callback))(); + std::exchange(Emu.after_kill_callback, nullptr)(); } return game_boot_result::no_errors;