From 80704d013e43ba29d2e1fd683373227987b91dcb Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Feb 2014 17:35:43 -0800 Subject: [PATCH] Fix #5390, crash on Exit on Windows. --- Core/Core.cpp | 4 +++- Windows/EmuThread.cpp | 2 +- Windows/WindowsHost.cpp | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Core/Core.cpp b/Core/Core.cpp index cf4ceb0fc4..2a44f38b78 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -139,7 +139,9 @@ static inline void UpdateRunLoop() { NativeUpdate(input_state); EndInputState(&input_state); } - NativeRender(); + if (globalUIState != UISTATE_EXIT) { + NativeRender(); + } } void Core_RunLoop() { diff --git a/Windows/EmuThread.cpp b/Windows/EmuThread.cpp index e121a7e118..7d203b1f25 100644 --- a/Windows/EmuThread.cpp +++ b/Windows/EmuThread.cpp @@ -55,7 +55,7 @@ void EmuThread_Stop() // Already stopped? { lock_guard guard(emuThreadLock); - if (emuThread == NULL) + if (emuThread == NULL || emuThreadReady == THREAD_END) return; } diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index dd0d443153..039d0f4ff5 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -104,6 +104,7 @@ bool WindowsHost::InitGL(std::string *error_message) void WindowsHost::ShutdownGL() { GL_Shutdown(); + PostMessage(MainWindow::GetHWND(), WM_CLOSE, 0, 0); } void WindowsHost::SetWindowTitle(const char *message)