From 750359d780f3c3ed2f7962f9ac7b7ea79426c663 Mon Sep 17 00:00:00 2001 From: Eladash <18193363+elad335@users.noreply.github.com> Date: Wed, 27 Mar 2024 10:40:25 +0200 Subject: [PATCH] Fixup emulation stopping --- rpcs3/Emu/Cell/PPUThread.cpp | 3 ++- rpcs3/Emu/System.cpp | 18 +++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 6fcf32c454..c180c00e8c 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -3377,11 +3377,12 @@ static bool ppu_store_reservation(ppu_thread& ppu, u32 addr, u64 reg_value) data += 0; auto range_lock = vm::alloc_range_lock(); + bool success = false; { rsx::reservation_lock rsx_lock(addr, 128); auto& super_data = *vm::get_super_ptr(addr); - const bool success = [&]() + success = [&]() { // Full lock (heavyweight) // TODO: vm::check_addr diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index a079b09703..ace93740d0 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -2736,6 +2736,17 @@ void Emulator::GracefulShutdown(bool allow_autoexit, bool async_op, bool savesta return; } + if (!savestate && m_emu_state_close_pending) + { + while (!async_op && m_state != system_state::stopped) + { + process_qt_events(); + std::this_thread::sleep_for(16ms); + } + + return; + } + if (old_state == system_state::paused) { Resume(); @@ -2759,11 +2770,6 @@ void Emulator::GracefulShutdown(bool allow_autoexit, bool async_op, bool savesta auto perform_kill = [read_counter, allow_autoexit, this, info = GetEmulationIdentifier()]() { - if (m_emu_state_close_pending.exchange(true)) - { - return; - } - bool read_sysutil_signal = false; for (u32 i = 100; i < 140; i++) @@ -2786,7 +2792,6 @@ void Emulator::GracefulShutdown(bool allow_autoexit, bool async_op, bool savesta if (static_cast(info) != m_stop_ctr) { - m_emu_state_close_pending = false; return; } } @@ -2794,7 +2799,6 @@ void Emulator::GracefulShutdown(bool allow_autoexit, bool async_op, bool savesta // An inevitable attempt to terminate the *current* emulation course will be issued after 7s CallFromMainThread([allow_autoexit, this]() { - m_emu_state_close_pending = false; Kill(allow_autoexit); }, info); };