From 4b9056fa02fb3be0ba13f1b834ac565cd86947a4 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 28 Sep 2013 00:32:45 -0700 Subject: [PATCH] Shutdown cleanly even when GE debugger is paused. --- Core/Core.cpp | 14 ++++++++++++++ Core/Core.h | 3 +++ Core/System.cpp | 1 + Windows/GEDebugger/GEDebugger.cpp | 12 ++++++++++++ 4 files changed, 30 insertions(+) diff --git a/Core/Core.cpp b/Core/Core.cpp index ef94383213..a39ae0175e 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -15,6 +15,7 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include #include "base/NativeApp.h" #include "base/display.h" #include "base/mutex.h" @@ -42,6 +43,7 @@ static recursive_mutex m_hStepMutex; static event m_hInactiveEvent; static recursive_mutex m_hInactiveMutex; static bool singleStepPending = false; +static std::set shutdownFuncs; #ifdef _WIN32 InputState input_state; @@ -49,6 +51,17 @@ InputState input_state; extern InputState input_state; #endif +void Core_ListenShutdown(Core_ShutdownFunc func) +{ + shutdownFuncs.insert(func); +} + +void Core_NotifyShutdown() +{ + for (auto it = shutdownFuncs.begin(); it != shutdownFuncs.end(); ++it) + (*it)(); +} + void Core_ErrorPause() { Core_UpdateState(CORE_ERROR); @@ -63,6 +76,7 @@ void Core_Halt(const char *msg) void Core_Stop() { + Core_NotifyShutdown(); Core_UpdateState(CORE_POWERDOWN); m_hStepEvent.notify_one(); } diff --git a/Core/Core.h b/Core/Core.h index 70d21945d0..6d85191ebd 100644 --- a/Core/Core.h +++ b/Core/Core.h @@ -30,6 +30,9 @@ void Core_EnableStepping(bool step); void Core_DoSingleStep(); void Core_UpdateSingleStep(); +typedef void (* Core_ShutdownFunc)(); +void Core_ListenShutdown(Core_ShutdownFunc func); +void Core_NotifyShutdown(); void Core_Halt(const char *msg); bool Core_IsStepping(); diff --git a/Core/System.cpp b/Core/System.cpp index 967dab486e..51cb2a8baa 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -286,6 +286,7 @@ bool PSP_IsInited() { } void PSP_Shutdown() { + Core_NotifyShutdown(); if (coreState == CORE_RUNNING) Core_UpdateState(CORE_ERROR); if (cpuThread != NULL) { diff --git a/Windows/GEDebugger/GEDebugger.cpp b/Windows/GEDebugger/GEDebugger.cpp index 189ee1899e..00f5f47221 100644 --- a/Windows/GEDebugger/GEDebugger.cpp +++ b/Windows/GEDebugger/GEDebugger.cpp @@ -96,9 +96,17 @@ static void RunPauseAction() { pauseAction = PAUSE_CONTINUE; } +static void ForceUnpause() { + lock_guard guard(pauseLock); + lock_guard actionGuard(actionLock); + pauseAction = PAUSE_CONTINUE; + pauseWait.notify_one(); +} + CGEDebugger::CGEDebugger(HINSTANCE _hInstance, HWND _hParent) : Dialog((LPCSTR)IDD_GEDEBUGGER, _hInstance, _hParent), frameWindow(NULL), texWindow(NULL) { breakCmds.resize(256, false); + Core_ListenShutdown(ForceUnpause); // it's ugly, but .rc coordinates don't match actual pixels and it screws // up both the size and the aspect ratio @@ -239,6 +247,10 @@ bool WindowsHost::GPUDebuggingActive() { static void PauseWithMessage(UINT msg, WPARAM wParam = NULL, LPARAM lParam = NULL) { lock_guard guard(pauseLock); + if (Core_IsInactive()) { + return; + } + PostMessage(geDebuggerWindow->GetDlgHandle(), msg, wParam, lParam); do {