DolphinQt: Don't update debug widgets when hidden

Saves on CPU usage when pausing/unpausing with the debugger disabled.
This is especially important when using frame advance rapidly.
This commit is contained in:
JosJuice 2019-07-06 10:50:11 +02:00
parent 0a7395bfba
commit 92a655c8b9
14 changed files with 108 additions and 32 deletions

View File

@ -41,14 +41,8 @@ BreakpointWidget::BreakpointWidget(QWidget* parent) : QDockWidget(parent)
CreateWidgets();
connect(&Settings::Instance(), &Settings::EmulationStateChanged, [this](Core::State state) {
if (!Settings::Instance().IsDebugModeEnabled())
return;
bool is_initialised = state != Core::State::Uninitialized;
m_new->setEnabled(is_initialised);
m_load->setEnabled(is_initialised);
m_save->setEnabled(is_initialised);
if (!is_initialised)
UpdateButtonsEnabled();
if (state == Core::State::Uninitialized)
{
PowerPC::breakpoints.Clear();
PowerPC::memchecks.Clear();
@ -65,8 +59,6 @@ BreakpointWidget::BreakpointWidget(QWidget* parent) : QDockWidget(parent)
connect(&Settings::Instance(), &Settings::ThemeChanged, this, &BreakpointWidget::UpdateIcons);
UpdateIcons();
Update();
}
BreakpointWidget::~BreakpointWidget()
@ -138,8 +130,28 @@ void BreakpointWidget::closeEvent(QCloseEvent*)
Settings::Instance().SetBreakpointsVisible(false);
}
void BreakpointWidget::showEvent(QShowEvent* event)
{
UpdateButtonsEnabled();
Update();
}
void BreakpointWidget::UpdateButtonsEnabled()
{
if (!isVisible())
return;
const bool is_initialised = Core::GetState() != Core::State::Uninitialized;
m_new->setEnabled(is_initialised);
m_load->setEnabled(is_initialised);
m_save->setEnabled(is_initialised);
}
void BreakpointWidget::Update()
{
if (!isVisible())
return;
m_table->clear();
m_table->setHorizontalHeaderLabels(

View File

@ -9,9 +9,10 @@
#include "Common/CommonTypes.h"
class QAction;
class QCloseEvent;
class QShowEvent;
class QTableWidget;
class QToolBar;
class QCloseEvent;
class BreakpointWidget : public QDockWidget
{
@ -25,6 +26,7 @@ public:
bool do_break = true);
void AddRangedMBP(u32 from, u32 to, bool do_read = true, bool do_write = true, bool do_log = true,
bool do_break = true);
void UpdateButtonsEnabled();
void Update();
signals:
@ -33,6 +35,7 @@ signals:
protected:
void closeEvent(QCloseEvent*) override;
void showEvent(QShowEvent* event) override;
private:
void CreateWidgets();

View File

@ -92,6 +92,9 @@ void CodeViewWidget::FontBasedSizing()
void CodeViewWidget::Update()
{
if (!isVisible())
return;
if (m_updating)
return;
@ -568,6 +571,11 @@ void CodeViewWidget::mousePressEvent(QMouseEvent* event)
}
}
void CodeViewWidget::showEvent(QShowEvent* event)
{
Update();
}
void CodeViewWidget::ToggleBreakpoint()
{
if (PowerPC::debug_interface.IsBreakpoint(GetContextAddress()))

View File

@ -13,6 +13,7 @@
class QKeyEvent;
class QMouseEvent;
class QResizeEvent;
class QShowEvent;
class CodeViewWidget : public QTableWidget
{
@ -56,6 +57,7 @@ private:
void keyPressEvent(QKeyEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
void wheelEvent(QWheelEvent* event) override;
void showEvent(QShowEvent* event) override;
void OnContextMenu();

View File

@ -64,8 +64,6 @@ CodeWidget::CodeWidget(QWidget* parent) : QDockWidget(parent)
settings.value(QStringLiteral("codewidget/codesplitter")).toByteArray());
m_box_splitter->restoreState(
settings.value(QStringLiteral("codewidget/boxsplitter")).toByteArray());
Update();
}
CodeWidget::~CodeWidget()
@ -83,6 +81,11 @@ void CodeWidget::closeEvent(QCloseEvent*)
Settings::Instance().SetCodeVisible(false);
}
void CodeWidget::showEvent(QShowEvent* event)
{
Update();
}
void CodeWidget::CreateWidgets()
{
auto* layout = new QGridLayout;
@ -265,6 +268,9 @@ void CodeWidget::SetAddress(u32 address, CodeViewWidget::SetAddressUpdate update
void CodeWidget::Update()
{
if (!isVisible())
return;
const Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(m_code_view->GetAddress());
UpdateCallstack();

View File

@ -12,6 +12,7 @@
class QCloseEvent;
class QLineEdit;
class QShowEvent;
class QSplitter;
class QListWidget;
class QTableWidget;
@ -61,6 +62,7 @@ private:
void OnSelectFunctionCalls();
void closeEvent(QCloseEvent*) override;
void showEvent(QShowEvent* event) override;
QLineEdit* m_search_address;
QLineEdit* m_search_symbols;

View File

@ -57,8 +57,6 @@ JITWidget::JITWidget(QWidget* parent) : QDockWidget(parent)
#else
m_disassembler = GetNewDisassembler("UNK");
#endif
Update();
}
JITWidget::~JITWidget()
@ -126,6 +124,9 @@ void JITWidget::Compare(u32 address)
void JITWidget::Update()
{
if (!isVisible())
return;
if (!m_address)
{
m_ppc_asm_widget->setHtml(QStringLiteral("<i>%1</i>").arg(tr("(ppc)")));
@ -208,3 +209,8 @@ void JITWidget::closeEvent(QCloseEvent*)
{
Settings::Instance().SetJITVisible(false);
}
void JITWidget::showEvent(QShowEvent* event)
{
Update();
}

View File

@ -10,6 +10,7 @@
#include "Common/CommonTypes.h"
class QCloseEvent;
class QShowEvent;
class QSplitter;
class QTextBrowser;
class QTableWidget;
@ -31,6 +32,7 @@ private:
void ConnectWidgets();
void closeEvent(QCloseEvent*) override;
void showEvent(QShowEvent* event) override;
QTableWidget* m_table_widget;
QTextBrowser* m_ppc_asm_widget;

View File

@ -57,7 +57,6 @@ MemoryWidget::MemoryWidget(QWidget* parent) : QDockWidget(parent)
LoadSettings();
ConnectWidgets();
Update();
OnAddressSpaceChanged();
OnTypeChanged();
}
@ -258,8 +257,16 @@ void MemoryWidget::closeEvent(QCloseEvent*)
Settings::Instance().SetMemoryVisible(false);
}
void MemoryWidget::showEvent(QShowEvent* event)
{
Update();
}
void MemoryWidget::Update()
{
if (!isVisible())
return;
m_memory_view->Update();
update();
}

View File

@ -17,6 +17,7 @@ class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class QShowEvent;
class QSplitter;
class MemoryWidget : public QDockWidget
@ -61,6 +62,7 @@ private:
void FindValue(bool next);
void closeEvent(QCloseEvent*) override;
void showEvent(QShowEvent* event) override;
MemoryViewWidget* m_memory_view;
QSplitter* m_splitter;

View File

@ -38,14 +38,7 @@ RegisterWidget::RegisterWidget(QWidget* parent) : QDockWidget(parent)
PopulateTable();
ConnectWidgets();
connect(Host::GetInstance(), &Host::UpdateDisasmDialog, this, [this] {
if (Settings::Instance().IsDebugModeEnabled() && Core::GetState() == Core::State::Paused)
{
m_updating = true;
emit UpdateTable();
m_updating = false;
}
});
connect(Host::GetInstance(), &Host::UpdateDisasmDialog, this, &RegisterWidget::Update);
connect(&Settings::Instance(), &Settings::RegistersVisibilityChanged,
[this](bool visible) { setHidden(!visible); });
@ -68,6 +61,11 @@ void RegisterWidget::closeEvent(QCloseEvent*)
Settings::Instance().SetRegistersVisible(false);
}
void RegisterWidget::showEvent(QShowEvent* event)
{
Update();
}
void RegisterWidget::CreateWidgets()
{
m_table = new QTableWidget;
@ -375,3 +373,13 @@ void RegisterWidget::AddRegister(int row, int column, RegisterType type, std::st
connect(this, &RegisterWidget::UpdateTable, [value] { value->RefreshValue(); });
}
void RegisterWidget::Update()
{
if (isVisible() && Core::GetState() == Core::State::Paused)
{
m_updating = true;
emit UpdateTable();
m_updating = false;
}
}

View File

@ -13,6 +13,7 @@
class QTableWidget;
class QCloseEvent;
class QShowEvent;
class RegisterWidget : public QDockWidget
{
@ -30,6 +31,7 @@ signals:
protected:
void closeEvent(QCloseEvent*) override;
void showEvent(QShowEvent* event) override;
private:
void CreateWidgets();
@ -42,6 +44,8 @@ private:
void AddRegister(int row, int column, RegisterType type, std::string register_name,
std::function<u64()> get_reg, std::function<void(u64)> set_reg);
void Update();
QTableWidget* m_table;
bool m_updating = false;
};

View File

@ -43,12 +43,7 @@ WatchWidget::WatchWidget(QWidget* parent) : QDockWidget(parent)
ConnectWidgets();
connect(&Settings::Instance(), &Settings::EmulationStateChanged, [this](Core::State state) {
if (!Settings::Instance().IsDebugModeEnabled())
return;
m_load->setEnabled(Core::IsRunning());
m_save->setEnabled(Core::IsRunning());
UpdateButtonsEnabled();
if (state != Core::State::Starting)
Update();
});
@ -61,8 +56,6 @@ WatchWidget::WatchWidget(QWidget* parent) : QDockWidget(parent)
connect(&Settings::Instance(), &Settings::ThemeChanged, this, &WatchWidget::UpdateIcons);
UpdateIcons();
Update();
}
WatchWidget::~WatchWidget()
@ -117,8 +110,20 @@ void WatchWidget::UpdateIcons()
m_save->setIcon(Resources::GetScaledThemeIcon("debugger_save"));
}
void WatchWidget::UpdateButtonsEnabled()
{
if (!isVisible())
return;
m_load->setEnabled(Core::IsRunning());
m_save->setEnabled(Core::IsRunning());
}
void WatchWidget::Update()
{
if (!isVisible())
return;
m_updating = true;
m_table->clear();
@ -200,6 +205,12 @@ void WatchWidget::closeEvent(QCloseEvent*)
Settings::Instance().SetWatchVisible(false);
}
void WatchWidget::showEvent(QShowEvent* event)
{
UpdateButtonsEnabled();
Update();
}
void WatchWidget::OnLoad()
{
IniFile ini;

View File

@ -13,6 +13,7 @@ class QTableWidget;
class QTableWidgetItem;
class QToolBar;
class QCloseEvent;
class QShowEvent;
class WatchWidget : public QDockWidget
{
@ -27,6 +28,7 @@ signals:
protected:
void closeEvent(QCloseEvent*) override;
void showEvent(QShowEvent* event) override;
private:
void CreateWidgets();
@ -35,6 +37,7 @@ private:
void OnLoad();
void OnSave();
void UpdateButtonsEnabled();
void Update();
void ShowContextMenu();