From fb1c1eeaefe61aabad521e4ca73afe65e428a285 Mon Sep 17 00:00:00 2001 From: schm1dtmac Date: Mon, 11 May 2026 18:00:45 +0100 Subject: [PATCH] [System] Fix restart-loops upon restart-then-quit (#18723) I observed under macOS (although the bug seems platform agnostic to me) that when restarting a game, then subsequently quitting it, I'd get stuck in a 'restart loop' where the game would restart upon completely shutting down, and this would repeat every time I tried to close the game until I gave up & force quit RPCS3. Seems like for whatever reason, the use of std::move didn't actually guarantee that after_kill_callback got nuked if at all, so all I've done is take a hammer to the fucker and manually set it to nullptr after being called. Co-authored-by: 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..d0a9e15ebc 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(ensure(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(ensure(Emu.after_kill_callback), nullptr)(); } return game_boot_result::no_errors;