diff --git a/Core/Core.cpp b/Core/Core.cpp index 5e32d29af4..bb02a1c08d 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -54,7 +54,8 @@ static std::condition_variable m_InactiveCond; static std::mutex m_hInactiveMutex; static bool singleStepPending = false; static int steppingCounter = 0; -static std::set shutdownFuncs; +static std::set lifecycleFuncs; +static std::set stopFuncs; static bool windowHidden = false; static double lastActivity = 0.0; static double lastKeepAwake = 0.0; @@ -76,17 +77,24 @@ void Core_NotifyActivity() { } void Core_ListenLifecycle(CoreLifecycleFunc func) { - shutdownFuncs.insert(func); + lifecycleFuncs.insert(func); } void Core_NotifyLifecycle(CoreLifecycle stage) { - for (auto it = shutdownFuncs.begin(); it != shutdownFuncs.end(); ++it) { - (*it)(stage); + for (auto func : lifecycleFuncs) { + func(stage); } } +void Core_ListenStopRequest(CoreStopRequestFunc func) { + stopFuncs.insert(func); +} + void Core_Stop() { Core_UpdateState(CORE_POWERDOWN); + for (auto func : stopFuncs) { + func(); + } } bool Core_IsStepping() { diff --git a/Core/Core.h b/Core/Core.h index 0b87f2b393..69749f0d70 100644 --- a/Core/Core.h +++ b/Core/Core.h @@ -51,10 +51,15 @@ enum class CoreLifecycle { MEMORY_REINITED, }; +// Callback is called on the Emu thread. typedef void (* CoreLifecycleFunc)(CoreLifecycle stage); void Core_ListenLifecycle(CoreLifecycleFunc func); void Core_NotifyLifecycle(CoreLifecycle stage); +// Callback is executed on requesting thread. +typedef void (* CoreStopRequestFunc)(); +void Core_ListenStopRequest(CoreStopRequestFunc callback); + bool Core_IsStepping(); bool Core_IsActive(); diff --git a/GPU/Debugger/Stepping.cpp b/GPU/Debugger/Stepping.cpp index ea93778cff..c765d15b76 100644 --- a/GPU/Debugger/Stepping.cpp +++ b/GPU/Debugger/Stepping.cpp @@ -197,12 +197,10 @@ void ResumeFromStepping() { SetPauseAction(PAUSE_CONTINUE, false); } -void ForceUnpause(CoreLifecycle stage) { - if (stage == CoreLifecycle::STOPPING) { - SetPauseAction(PAUSE_CONTINUE, false); - actionComplete = true; - actionWait.notify_all(); - } +void ForceUnpause() { + SetPauseAction(PAUSE_CONTINUE, false); + actionComplete = true; + actionWait.notify_all(); } } // namespace diff --git a/GPU/Debugger/Stepping.h b/GPU/Debugger/Stepping.h index 3e9b5086cc..d99e8af904 100644 --- a/GPU/Debugger/Stepping.h +++ b/GPU/Debugger/Stepping.h @@ -38,5 +38,5 @@ namespace GPUStepping { bool GPU_SetCmdValue(u32 op); void ResumeFromStepping(); - void ForceUnpause(CoreLifecycle stage); + void ForceUnpause(); }; diff --git a/Windows/GEDebugger/GEDebugger.cpp b/Windows/GEDebugger/GEDebugger.cpp index e77238ba3b..ad68557f64 100644 --- a/Windows/GEDebugger/GEDebugger.cpp +++ b/Windows/GEDebugger/GEDebugger.cpp @@ -67,7 +67,7 @@ void CGEDebugger::Init() { CGEDebugger::CGEDebugger(HINSTANCE _hInstance, HWND _hParent) : Dialog((LPCSTR)IDD_GEDEBUGGER, _hInstance, _hParent) { GPUBreakpoints::Init(); - Core_ListenLifecycle(ForceUnpause); + Core_ListenStopRequest(ForceUnpause); // minimum size = a little more than the default RECT windowRect;