From ec729e2ee3f703a920aacf2394b821c24df9ec1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Fri, 23 Dec 2016 22:26:24 +0100 Subject: [PATCH] Stop Movie/Netplay before triggering STM shutdown This fixes a bug which caused Movie (input recording or playback) or netplay not to be stopped. DolphinWX previously triggered a STM power event, and then the STM directly stopped the emulation; the code which stops Movie/Netplay was completely skipped. This is fixed by moving it /before/ sending the shutdown event. --- Source/Core/DolphinWX/Frame.h | 1 + Source/Core/DolphinWX/FrameTools.cpp | 34 ++++++++++++++++------------ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Source/Core/DolphinWX/Frame.h b/Source/Core/DolphinWX/Frame.h index 805dea8967..faa3e320f8 100644 --- a/Source/Core/DolphinWX/Frame.h +++ b/Source/Core/DolphinWX/Frame.h @@ -90,6 +90,7 @@ public: void DoPause(); void DoStop(); + bool TriggerSTMPowerEvent(); void OnStopped(); void DoRecordingSave(); void UpdateGUI(); diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index cd68dff90e..515785ac12 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -824,20 +824,6 @@ void CFrame::DoStop() } } - const auto& stm = WII_IPC_HLE_Interface::GetDeviceByName("/dev/stm/eventhook"); - if (!m_tried_graceful_shutdown && stm && - std::static_pointer_cast(stm)->HasHookInstalled()) - { - Core::DisplayMessage("Shutting down", 30000); - // Unpause because gracefully shutting down needs the game to actually request a shutdown - if (Core::GetState() == Core::CORE_PAUSE) - DoPause(); - ProcessorInterface::PowerButton_Tap(); - m_confirmStop = false; - m_tried_graceful_shutdown = true; - return; - } - if (UseDebugger && g_pCodeWindow) { if (g_pCodeWindow->HasPanel()) @@ -862,11 +848,31 @@ void CFrame::DoStop() if (NetPlayDialog::GetNetPlayClient()) NetPlayDialog::GetNetPlayClient()->Stop(); + if (!m_tried_graceful_shutdown && TriggerSTMPowerEvent()) + { + m_tried_graceful_shutdown = true; + return; + } Core::Stop(); UpdateGUI(); } } +bool CFrame::TriggerSTMPowerEvent() +{ + const auto stm = WII_IPC_HLE_Interface::GetDeviceByName("/dev/stm/eventhook"); + if (!stm || !std::static_pointer_cast(stm)->HasHookInstalled()) + return false; + + Core::DisplayMessage("Shutting down", 30000); + // Unpause because gracefully shutting down needs the game to actually request a shutdown + if (Core::GetState() == Core::CORE_PAUSE) + DoPause(); + ProcessorInterface::PowerButton_Tap(); + m_confirmStop = false; + return true; +} + void CFrame::OnStopped() { m_confirmStop = false;