From 63546b4f2e6ca7926e6649c551c654e15e06b0cd Mon Sep 17 00:00:00 2001 From: aldelaro5 Date: Sat, 22 Oct 2016 17:20:06 -0400 Subject: [PATCH] Fix unnecessary Center PC calls in the CodeWindow This not only fixes a regression where toggling a breakpoint using the CodeWindow would cause a Center PC, but it also removes several redundant JumpToAddress(PC) calls. --- Source/Core/DolphinWX/Debugger/CodeWindow.cpp | 21 ++++++++++--------- Source/Core/DolphinWX/Debugger/CodeWindow.h | 2 +- Source/Core/DolphinWX/FrameTools.cpp | 16 +++++++------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Source/Core/DolphinWX/Debugger/CodeWindow.cpp b/Source/Core/DolphinWX/Debugger/CodeWindow.cpp index 388160f384..9cf243456d 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/CodeWindow.cpp @@ -159,7 +159,8 @@ void CCodeWindow::OnHostMessage(wxCommandEvent& event) break; case IDM_UPDATE_DISASM_DIALOG: - Repopulate(); + codeview->Center(PC); + Repopulate(false); if (HasPanel()) GetPanel()->NotifyUpdate(); if (HasPanel()) @@ -205,12 +206,14 @@ void CCodeWindow::OnCodeStep(wxCommandEvent& event) case IDM_SKIP: PC += 4; - Repopulate(); + codeview->Center(PC); + Repopulate(false); break; case IDM_SETPC: PC = codeview->GetSelection(); - Repopulate(); + codeview->Center(PC); + Repopulate(false); break; case IDM_GOTOPC: @@ -383,11 +386,8 @@ void CCodeWindow::StepOut() PowerPC::SetMode(old_mode); CPU::PauseAndLock(false, false); - JumpToAddress(PC); - { - wxCommandEvent ev(wxEVT_HOST_COMMAND, IDM_UPDATE_DISASM_DIALOG); - GetEventHandler()->ProcessEvent(ev); - } + wxCommandEvent ev(wxEVT_HOST_COMMAND, IDM_UPDATE_DISASM_DIALOG); + GetEventHandler()->ProcessEvent(ev); // Update all toolbars in the aui manager Parent->UpdateGUI(); @@ -605,12 +605,13 @@ void CCodeWindow::PopulateToolbar(wxToolBar* toolBar) } // Update GUI -void CCodeWindow::Repopulate() +void CCodeWindow::Repopulate(bool refresh_codeview) { if (!codeview) return; - codeview->Center(PC); + if (refresh_codeview) + codeview->Refresh(); UpdateCallstack(); UpdateButtonStates(); diff --git a/Source/Core/DolphinWX/Debugger/CodeWindow.h b/Source/Core/DolphinWX/Debugger/CodeWindow.h index ccd7f4163e..fd5ae5f7b7 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindow.h +++ b/Source/Core/DolphinWX/Debugger/CodeWindow.h @@ -95,7 +95,7 @@ public: bool JITNoBlockLinking(); bool JumpToAddress(u32 address); - void Repopulate(); + void Repopulate(bool refresh_codeview = true); void NotifyMapLoaded(); void PopulateToolbar(wxToolBar* toolBar); void UpdateButtonStates(); diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index a4e3a0ae52..7380583fe9 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -523,13 +523,15 @@ void CFrame::OnPlay(wxCommandEvent& WXUNUSED(event)) // Core is initialized and emulator is running if (UseDebugger) { - CPU::EnableStepping(!CPU::IsStepping()); - - wxThread::Sleep(20); - g_pCodeWindow->JumpToAddress(PC); - g_pCodeWindow->Repopulate(); - // Update toolbar with Play/Pause status - UpdateGUI(); + bool was_stopped = CPU::IsStepping(); + CPU::EnableStepping(!was_stopped); + // When the CPU stops it generates a IDM_UPDATE_DISASM_DIALOG which automatically refreshes + // the UI, the UI only needs to be refreshed manually when unpausing. + if (was_stopped) + { + g_pCodeWindow->Repopulate(); + UpdateGUI(); + } } else {