Merge pull request #12299 from TryTwo/PR_bugfix_frame_advance

Core: Add option to not report state change to SetState (bugfix)
This commit is contained in:
Admiral H. Curtiss 2023-11-22 23:10:51 +01:00 committed by GitHub
commit 937cb8ef3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 7 deletions

View File

@ -712,7 +712,7 @@ static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi
// Set or get the running state // Set or get the running state
void SetState(State state) void SetState(State state, bool report_state_change)
{ {
// State cannot be controlled until the CPU Thread is operational // State cannot be controlled until the CPU Thread is operational
if (!IsRunningAndStarted()) if (!IsRunningAndStarted())
@ -739,7 +739,10 @@ void SetState(State state)
break; break;
} }
CallOnStateChangedCallbacks(GetState()); // Certain callers only change the state momentarily. Sending a callback for them causes
// unwanted updates, such as the Pause/Play button flickering between states on frame advance.
if (report_state_change)
CallOnStateChangedCallbacks(GetState());
} }
State GetState() State GetState()
@ -750,7 +753,7 @@ State GetState()
if (s_hardware_initialized) if (s_hardware_initialized)
{ {
auto& system = Core::System::GetInstance(); auto& system = Core::System::GetInstance();
if (system.GetCPU().IsStepping() || s_frame_step) if (system.GetCPU().IsStepping())
return State::Paused; return State::Paused;
return State::Running; return State::Running;
@ -1083,7 +1086,7 @@ void DoFrameStep()
// if already paused, frame advance for 1 frame // if already paused, frame advance for 1 frame
s_stop_frame_step = false; s_stop_frame_step = false;
s_frame_step = true; s_frame_step = true;
SetState(State::Running); SetState(State::Running, false);
} }
else if (!s_frame_step) else if (!s_frame_step)
{ {

View File

@ -147,7 +147,7 @@ bool IsHostThread();
bool WantsDeterminism(); bool WantsDeterminism();
// [NOT THREADSAFE] For use by Host only // [NOT THREADSAFE] For use by Host only
void SetState(State state); void SetState(State state, bool report_state_change = true);
State GetState(); State GetState();
void SaveScreenShot(); void SaveScreenShot();

View File

@ -160,7 +160,7 @@ void CodeDiffDialog::ClearBlockCache()
Core::State old_state = Core::GetState(); Core::State old_state = Core::GetState();
if (old_state == Core::State::Running) if (old_state == Core::State::Running)
Core::SetState(Core::State::Paused); Core::SetState(Core::State::Paused, false);
Core::System::GetInstance().GetJitInterface().ClearCache(); Core::System::GetInstance().GetJitInterface().ClearCache();
@ -349,7 +349,7 @@ void CodeDiffDialog::Update(bool include)
// Wrap everything in a pause // Wrap everything in a pause
Core::State old_state = Core::GetState(); Core::State old_state = Core::GetState();
if (old_state == Core::State::Running) if (old_state == Core::State::Running)
Core::SetState(Core::State::Paused); Core::SetState(Core::State::Paused, false);
// Main process // Main process
if (include) if (include)