From 8773ebf64b55c4c51ddf0e2b99f222dc3a9e9bf5 Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Sun, 22 Jan 2023 17:23:24 +0000 Subject: [PATCH] VM: Queue shutdown message when called from inside emulation. --- pcsx2-qt/QtHost.cpp | 13 ++++++++++--- pcsx2/CDVD/CDVD.cpp | 6 +++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pcsx2-qt/QtHost.cpp b/pcsx2-qt/QtHost.cpp index 132a01a89e..abdbb94c44 100644 --- a/pcsx2-qt/QtHost.cpp +++ b/pcsx2-qt/QtHost.cpp @@ -1237,9 +1237,16 @@ void Host::RequestVMShutdown(bool allow_confirm, bool allow_save_state, bool def if (!VMManager::HasValidVM()) return; - // Run it on the host thread, that way we get the confirm prompt (if enabled). - QMetaObject::invokeMethod(g_main_window, "requestShutdown", Qt::QueuedConnection, Q_ARG(bool, allow_confirm), - Q_ARG(bool, allow_save_state), Q_ARG(bool, default_save_state), Q_ARG(bool, false)); + if (allow_confirm) + { + // Run it on the host thread, that way we get the confirm prompt (if enabled). + QMetaObject::invokeMethod(g_main_window, "requestShutdown", Qt::QueuedConnection, Q_ARG(bool, allow_confirm), + Q_ARG(bool, allow_save_state), Q_ARG(bool, default_save_state), Q_ARG(bool, false)); + } + else + { + g_emu_thread->shutdownVM(allow_save_state && default_save_state); + } } bool Host::IsFullscreen() diff --git a/pcsx2/CDVD/CDVD.cpp b/pcsx2/CDVD/CDVD.cpp index 3aafad33fa..f55e20e6ed 100644 --- a/pcsx2/CDVD/CDVD.cpp +++ b/pcsx2/CDVD/CDVD.cpp @@ -37,7 +37,7 @@ #include "Elfheader.h" #include "ps2/BiosTools.h" #include "Recording/InputRecording.h" -#include "VMManager.h" +#include "Host.h" // This typically reflects the Sony-assigned serial code for the Disc, if one exists. // (examples: SLUS-2113, etc). @@ -2440,8 +2440,8 @@ static void cdvdWrite16(u8 rt) // SCOMMAND case 0x0F: // sceCdPowerOff (0:1)- Call74 from Xcdvdman - Console.WriteLn(Color_StrongBlack, "sceCdPowerOff called. Resetting VM."); - VMManager::Reset(); + Console.WriteLn(Color_StrongBlack, "sceCdPowerOff called. Shutting down VM."); + Host::RequestVMShutdown(false, false, false); break; case 0x12: // sceCdReadILinkId (0:9)