Windows: Fix mis-interaction between no-menu pause and pause on window lost focus, reported by IRVN

This commit is contained in:
Henrik Rydgård 2025-01-23 14:32:38 +01:00
parent 3dc46666ff
commit 63a41e7635
3 changed files with 12 additions and 2 deletions

View file

@ -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<std::mutex> 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.

View file

@ -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);

View file

@ -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();
}
}