[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>
This commit is contained in:
schm1dtmac 2026-05-11 18:00:45 +01:00 committed by GitHub
parent 6fa7efbcc3
commit fb1c1eeaef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;