From 63a41e763576fe963ea45dd1a8bf639b359717ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 23 Jan 2025 14:32:38 +0100 Subject: [PATCH] Windows: Fix mis-interaction between no-menu pause and pause on window lost focus, reported by IRVN --- Core/Core.cpp | 10 +++++++++- Core/Core.h | 2 ++ Windows/MainWindow.cpp | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Core/Core.cpp b/Core/Core.cpp index c0b4ee853c..d6a1efeb55 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -81,6 +81,7 @@ volatile bool coreStatePending = false; static bool powerSaving = false; static bool g_breakAfterFrame = false; +static std::string g_breakReason; static MIPSExceptionInfo g_exceptionInfo; @@ -390,7 +391,6 @@ void Core_Break(const char *reason, u32 relatedAddress) { } { - // Stop the tracer std::lock_guard lock(g_stepMutex); if (!g_cpuStepCommand.empty() && Core_IsStepping()) { // If we're in a failed step that uses a temp breakpoint, we need to be able to override it here. @@ -404,7 +404,11 @@ void Core_Break(const char *reason, u32 relatedAddress) { return; } } + + // Stop the tracer mipsTracer.stop_tracing(); + + g_breakReason = reason; g_cpuStepCommand.type = CPUStepType::None; g_cpuStepCommand.reason = reason; g_cpuStepCommand.relatedAddr = relatedAddress; @@ -415,6 +419,10 @@ void Core_Break(const char *reason, u32 relatedAddress) { System_Notify(SystemNotification::DEBUG_MODE_CHANGE); } +const std::string &Core_BreakReason() { + return g_breakReason; +} + // Free-threaded (or at least should be) void Core_Resume() { // If the current PC is on a breakpoint, the user doesn't want to do nothing. diff --git a/Core/Core.h b/Core/Core.h index da08238533..ebcc8c249c 100644 --- a/Core/Core.h +++ b/Core/Core.h @@ -50,6 +50,8 @@ void Core_Break(const char *reason, u32 relatedAddress = 0); // Resumes execution. Works both when stepping the CPU and the GE. void Core_Resume(); +const std::string &Core_BreakReason(); + // This should be called externally. // Can fail if another step type was requested this frame. bool Core_RequestCPUStep(CPUStepType stepType, int stepSize); diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 9bac7160c6..e768ba5c6d 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -906,7 +906,7 @@ namespace MainWindow } else { if (pause) { Core_Break("ui.lost_focus", 0); - } else { + } else if (Core_BreakReason() == "ui.lost_focus") { Core_Resume(); } }