From 6d38dd982100b85d7887cba78782989cf5d9ec76 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sat, 4 Mar 2023 23:05:59 +0100 Subject: [PATCH] Qt/WatchWidget: Don't update if not paused. --- .../Core/DolphinQt/Debugger/WatchWidget.cpp | 46 ++++++++++++------- Source/Core/DolphinQt/Debugger/WatchWidget.h | 1 + 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/Source/Core/DolphinQt/Debugger/WatchWidget.cpp b/Source/Core/DolphinQt/Debugger/WatchWidget.cpp index e580c32b68..70bbcd57d6 100644 --- a/Source/Core/DolphinQt/Debugger/WatchWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/WatchWidget.cpp @@ -85,6 +85,16 @@ void WatchWidget::CreateWidgets() m_table->setContextMenuPolicy(Qt::CustomContextMenu); m_table->setSelectionMode(QAbstractItemView::ExtendedSelection); m_table->setSelectionBehavior(QAbstractItemView::SelectRows); + m_table->setHorizontalHeaderLabels( + {tr("Label"), tr("Address"), tr("Hexadecimal"), + // i18n: The base 10 numeral system. Not related to non-integer numbers + tr("Decimal"), + // i18n: Data type used in computing + tr("String"), + // i18n: Floating-point (non-integer) number + tr("Float"), tr("Locked")}); + m_table->setRowCount(1); + SetEmptyRow(0); m_new = m_toolbar->addAction(tr("New"), this, &WatchWidget::OnNewWatch); m_delete = m_toolbar->addAction(tr("Delete"), this, &WatchWidget::OnDelete); @@ -146,23 +156,22 @@ void WatchWidget::Update() m_updating = true; - m_table->clear(); + if (Core::GetState() != Core::State::Paused) + { + m_table->setDisabled(true); + m_updating = false; + return; + } + + m_table->setDisabled(false); + m_table->clearContents(); + + Core::CPUThreadGuard guard; int size = static_cast(PowerPC::debug_interface.GetWatches().size()); m_table->setRowCount(size + 1); - m_table->setHorizontalHeaderLabels( - {tr("Label"), tr("Address"), tr("Hexadecimal"), - // i18n: The base 10 numeral system. Not related to non-integer numbers - tr("Decimal"), - // i18n: Data type used in computing - tr("String"), - // i18n: Floating-point (non-integer) number - tr("Float"), tr("Locked")}); - - Core::CPUThreadGuard guard; - for (int i = 0; i < size; i++) { const auto& entry = PowerPC::debug_interface.GetWatch(i); @@ -211,19 +220,24 @@ void WatchWidget::Update() } } + SetEmptyRow(size); + + m_updating = false; +} + +void WatchWidget::SetEmptyRow(int row) +{ auto* label = new QTableWidgetItem; label->setData(Qt::UserRole, -1); - m_table->setItem(size, 0, label); + m_table->setItem(row, 0, label); for (int i = 1; i < NUM_COLUMNS; i++) { auto* no_edit = new QTableWidgetItem; no_edit->setFlags(Qt::ItemIsEnabled); - m_table->setItem(size, i, no_edit); + m_table->setItem(row, i, no_edit); } - - m_updating = false; } void WatchWidget::closeEvent(QCloseEvent*) diff --git a/Source/Core/DolphinQt/Debugger/WatchWidget.h b/Source/Core/DolphinQt/Debugger/WatchWidget.h index 1e3ad76e65..7d8711e39c 100644 --- a/Source/Core/DolphinQt/Debugger/WatchWidget.h +++ b/Source/Core/DolphinQt/Debugger/WatchWidget.h @@ -48,6 +48,7 @@ private: void UpdateButtonsEnabled(); void Update(); + void SetEmptyRow(int row); void ShowContextMenu(); void OnItemChanged(QTableWidgetItem* item);