From 43f33a2e77b0d17e7fe8e334e30d0d5fbf3b9f57 Mon Sep 17 00:00:00 2001 From: Nav Date: Thu, 21 Jul 2022 21:33:39 +0100 Subject: [PATCH] Corrected bug where memory inspection panes were not automatically fetching data upon the first target halt --- .../TargetMemoryInspectionPane.cpp | 15 +++++++++------ .../TargetMemoryInspectionPane.hpp | 4 +++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp index 11c7219e..1cacfc5a 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp @@ -212,8 +212,8 @@ namespace Bloom::Widgets readMemoryTask, &ReadTargetMemory::targetMemoryRead, this, - [this] (const Targets::TargetMemoryBuffer& buffer) { - this->onMemoryRead(buffer); + [this] (const Targets::TargetMemoryBuffer& data) { + this->onMemoryRead(data); // Refresh the stack pointer if this is RAM. if (this->targetMemoryDescriptor.type == Targets::TargetMemoryType::RAM) { @@ -264,7 +264,7 @@ namespace Bloom::Widgets void TargetMemoryInspectionPane::postActivate() { if ( - this->settings.refreshOnActivation + (this->settings.refreshOnActivation || !this->data.has_value()) && this->targetState == Targets::TargetState::STOPPED ) { this->refreshMemoryValues([this] { @@ -344,7 +344,7 @@ namespace Bloom::Widgets this->targetState = newState; if (newState == TargetState::STOPPED && this->activated) { - if (this->settings.refreshOnTargetStop) { + if (this->settings.refreshOnTargetStop || !this->data.has_value()) { this->refreshMemoryValues([this] { this->hexViewerWidget->setDisabled(false); }); @@ -368,8 +368,11 @@ namespace Bloom::Widgets this->settings.refreshOnActivation = enabled; } - void TargetMemoryInspectionPane::onMemoryRead(const Targets::TargetMemoryBuffer& buffer) { - this->hexViewerWidget->updateValues(buffer); + void TargetMemoryInspectionPane::onMemoryRead(const Targets::TargetMemoryBuffer& data) { + assert(data.size() == this->targetMemoryDescriptor.size()); + + this->data = data; + this->hexViewerWidget->updateValues(this->data.value()); } void TargetMemoryInspectionPane::openMemoryRegionManagerWindow() { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp index 29fb0011..0a3c8b2e 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp @@ -48,6 +48,8 @@ namespace Bloom::Widgets const Targets::TargetMemoryDescriptor& targetMemoryDescriptor; InsightWorker& insightWorker; + std::optional data; + QWidget* container = nullptr; QWidget* titleBar = nullptr; @@ -69,7 +71,7 @@ namespace Bloom::Widgets void onTargetStateChanged(Targets::TargetState newState); void setRefreshOnTargetStopEnabled(bool enabled); void setRefreshOnActivationEnabled(bool enabled); - void onMemoryRead(const Targets::TargetMemoryBuffer& buffer); + void onMemoryRead(const Targets::TargetMemoryBuffer& data); void openMemoryRegionManagerWindow(); void onMemoryRegionsChange(); void onProgrammingModeEnabled();