From 3266394dfbb564f69e3cd6470ad608a4db314916 Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Fri, 20 Jun 2014 02:43:57 +0200 Subject: Make the emulation stop asynchronous to prevent deadlocks. This may expose bugs which relied on the Main Thread to be suspended in the stopping state. --- Source/Core/DolphinWX/Frame.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Source/Core/DolphinWX/Frame.cpp') diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 5284eefd57..1807c5e53b 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -425,6 +425,7 @@ CFrame::CFrame(wxFrame* parent, Movie::SetInputManip(TASManipFunction); State::SetOnAfterLoadCallback(OnAfterLoadCallback); + Core::SetOnStoppedCallback(OnStoppedCallback); // Setup perspectives if (g_pCodeWindow) @@ -692,6 +693,10 @@ void CFrame::OnHostMessage(wxCommandEvent& event) case WM_USER_STOP: DoStop(); break; + + case IDM_STOPPED: + OnStopped(); + break; } } @@ -904,6 +909,16 @@ void OnAfterLoadCallback() } } +void OnStoppedCallback() +{ + // warning: this gets called from the EmuThread, so we should only queue things to do on the proper thread + if (main_frame) + { + wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_STOPPED); + main_frame->GetEventHandler()->AddPendingEvent(event); + } +} + void TASManipFunction(SPADStatus *PadStatus, int controllerID) { if (main_frame) -- cgit v1.2.3 From b30d5dccbe46c4bf9977a1437a826d082abebee0 Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Fri, 20 Jun 2014 03:03:00 +0200 Subject: Frame: OnClose now handles asynchronous behaviour of DoStop(). --- Source/Core/DolphinWX/Frame.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'Source/Core/DolphinWX/Frame.cpp') diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 1807c5e53b..38b8ae7df0 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -352,7 +352,7 @@ CFrame::CFrame(wxFrame* parent, , m_LogWindow(nullptr), m_LogConfigWindow(nullptr) , m_FifoPlayerDlg(nullptr), UseDebugger(_UseDebugger) , m_bBatchMode(_BatchMode), m_bEdit(false), m_bTabSplit(false), m_bNoDocking(false) - , m_bGameLoading(false) + , m_bGameLoading(false), m_bClosing(false) { for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++) bFloatWindow[i] = false; @@ -536,15 +536,18 @@ void CFrame::OnActive(wxActivateEvent& event) void CFrame::OnClose(wxCloseEvent& event) { + m_bClosing = true; + + // Before closing the window we need to shut down the emulation core. + // We'll try to close this window again once that is done. if (Core::GetState() != Core::CORE_UNINITIALIZED) { DoStop(); - if (Core::GetState() != Core::CORE_UNINITIALIZED) - return; - UpdateGUI(); + event.Veto(); + return; } - //Stop Dolphin from saving the minimized Xpos and Ypos + // Stop Dolphin from saving the minimized Xpos and Ypos if (main_frame->IsIconized()) main_frame->Iconize(false); -- cgit v1.2.3 From db7e746cb423de5ca47be7a3df7c4918a610ff5a Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Tue, 8 Jul 2014 00:47:57 +0200 Subject: Check whether the core is running instead of checking if it is unitialized. This properly handles the stopping state and more accurately represents the intended check. --- Source/Core/DolphinWX/Frame.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'Source/Core/DolphinWX/Frame.cpp') diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 38b8ae7df0..03cc67250d 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -217,7 +217,7 @@ WXLRESULT CRenderFrame::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPa case WM_CLOSE: // Let Core finish initializing before accepting any WM_CLOSE messages - if (Core::GetState() == Core::CORE_UNINITIALIZED) break; + if (!Core::IsRunning()) break; // Use default action otherwise default: @@ -722,7 +722,7 @@ void CFrame::GetRenderWindowSize(int& x, int& y, int& width, int& height) void CFrame::OnRenderWindowSizeRequest(int width, int height) { - if (Core::GetState() == Core::CORE_UNINITIALIZED || + if (!Core::IsRunning() || !SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderWindowAutoSize || RendererIsFullscreen() || m_RenderFrame->IsMaximized()) return; @@ -1109,8 +1109,7 @@ void CFrame::OnKeyDown(wxKeyEvent& event) void CFrame::OnKeyUp(wxKeyEvent& event) { - if(Core::GetState() != Core::CORE_UNINITIALIZED && - (RendererHasFocus() || TASInputHasFocus())) + if(Core::IsRunning() && (RendererHasFocus() || TASInputHasFocus())) { if (IsHotkey(event, HK_TOGGLE_THROTTLE)) { -- cgit v1.2.3