Fix Emulation::CallAfter

Most CallAfter usages were extremely wrong when ordered after Emu.Stop(). could result in anywhere from emulation stopping hangs to even segfaults.
track_emu_state = true is now the default, I haven't found cases which need need it disabled.
This commit is contained in:
Eladash 2021-02-13 18:05:31 +02:00 committed by Ivan
parent 68a878264c
commit 112b7f6571
5 changed files with 40 additions and 23 deletions

View file

@ -336,15 +336,8 @@ void _sys_process_exit(ppu_thread& ppu, s32 status, u32 arg2, u32 arg3)
sys_process.warning("_sys_process_exit(status=%d, arg2=0x%x, arg3=0x%x)", status, arg2, arg3);
// Get shared ptr to current PPU
Emu.CallAfter([s_ppu = idm::get<named_thread<ppu_thread>>(ppu.id)]()
Emu.CallAfter([]()
{
if (s_ppu->is_stopped())
{
// Stop() was already executed from a signal before
return;
}
sys_process.success("Process finished");
Emu.Stop();
});
@ -408,14 +401,8 @@ void _sys_process_exit2(ppu_thread& ppu, s32 status, vm::ptr<sys_exit2_param> ar
if (disc.empty() && !Emu.GetTitleID().empty())
disc = vfs::get(Emu.GetDir());
Emu.CallAfter([s_ppu = idm::get<named_thread<ppu_thread>>(ppu.id), path = std::move(path), argv = std::move(argv), envp = std::move(envp), data = std::move(data), disc = std::move(disc), hdd1 = std::move(hdd1), klic = g_fxo->get<loaded_npdrm_keys>()->devKlic.load()]() mutable
Emu.CallAfter([path = std::move(path), argv = std::move(argv), envp = std::move(envp), data = std::move(data), disc = std::move(disc), hdd1 = std::move(hdd1), klic = g_fxo->get<loaded_npdrm_keys>()->devKlic.load()]() mutable
{
if (s_ppu->is_stopped())
{
// Stop() was already executed from a signal before
return;
}
sys_process.success("Process finished -> %s", argv[0]);
Emu.SetForceBoot(true);
Emu.Stop();