Fix restart-loops upon restart-then-quit

(std::exchange one-liner courtesy of Elad <18193363+elad335@users.noreply.github.com>)
This commit is contained in:
schm1dtmac 2026-05-11 17:00:14 +01:00
parent 6fa7efbcc3
commit 9256a0277f

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