diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index da7251e291..f198156d47 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -70,6 +70,8 @@ LOG_CHANNEL(sys_log, "SYS"); // Preallocate 32 MiB stx::manual_typemap g_fixed_typemap; +static constinit atomic_t s_emulator_available{false}; + std::string g_cfg_defaults; atomic_t g_watchdog_hold_ctr{0}; @@ -118,6 +120,21 @@ namespace rsx void set_native_ui_flip(); } +Emulator::Emulator() noexcept +{ + s_emulator_available = true; +} + +Emulator::~Emulator() noexcept +{ + s_emulator_available = false; +} + +bool Emulator::IsAvailable() noexcept +{ + return s_emulator_available.load(); +} + template<> void fmt_class_string::format(std::string& out, u64 arg) { diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index ac2243389c..a38b65089f 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -201,8 +201,10 @@ public: static constexpr std::string_view game_id_boot_prefix = "%RPCS3_GAMEID%:"; static constexpr std::string_view vfs_boot_prefix = "%RPCS3_VFS%:"; - Emulator() noexcept = default; - ~Emulator() noexcept = default; + Emulator() noexcept; + ~Emulator() noexcept; + + static bool IsAvailable() noexcept; void SetCallbacks(EmuCallbacks&& cb) { diff --git a/rpcs3/rpcs3.cpp b/rpcs3/rpcs3.cpp index 90d92cf1bd..2030fc58b4 100644 --- a/rpcs3/rpcs3.cpp +++ b/rpcs3/rpcs3.cpp @@ -185,16 +185,23 @@ std::set get_one_drive_paths() fmt::append(buf, "\nSerialized Object: %s", g_tls_serialize_name); } - const system_state state = Emu.GetStatus(false); - - if (state == system_state::stopped) + if (Emulator::IsAvailable()) { - fmt::append(buf, "\nEmulation is stopped"); + const system_state state = Emu.GetStatus(false); + + if (state == system_state::stopped) + { + fmt::append(buf, "\nEmulation is stopped"); + } + else + { + const std::string name = Emu.GetTitleAndTitleID(); + fmt::append(buf, "\nTitle: \"%s\" (emulation is %s)", name.empty() ? "N/A" : name.c_str(), state == system_state::stopping ? "stopping" : "running"); + } } else { - const std::string& name = Emu.GetTitleAndTitleID(); - fmt::append(buf, "\nTitle: \"%s\" (emulation is %s)", name.empty() ? "N/A" : name.data(), state == system_state::stopping ? "stopping" : "running"); + fmt::append(buf, "\nEmulation object is unavailable (process teardown)"); } fmt::append(buf, "\nBuild: \"%s\"", rpcs3::get_verbose_version());