From 08977e8e0cb7eac68efce8acb6e21ac4948d4ba4 Mon Sep 17 00:00:00 2001 From: Nav Date: Sun, 24 Jul 2022 12:44:31 +0100 Subject: [PATCH] Updated MemoryInspectionPane to prevent it from enabling UI too early (before stack pointer retrieval) for RAM --- .../TargetMemoryInspectionPane.cpp | 59 +++++++++++++------ 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp index 1cacfc5a..7282b68e 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp @@ -212,7 +212,7 @@ namespace Bloom::Widgets readMemoryTask, &ReadTargetMemory::targetMemoryRead, this, - [this] (const Targets::TargetMemoryBuffer& data) { + [this, callback] (const Targets::TargetMemoryBuffer& data) { this->onMemoryRead(data); // Refresh the stack pointer if this is RAM. @@ -227,31 +227,56 @@ namespace Bloom::Widgets } ); + QObject::connect( + readStackPointerTask, + &InsightWorkerTask::finished, + this, + [this] { + this->refreshButton->stopSpin(); + + if (this->targetState == Targets::TargetState::STOPPED) { + this->refreshButton->setDisabled(false); + } + } + ); + + if (callback.has_value()) { + QObject::connect( + readStackPointerTask, + &InsightWorkerTask::completed, + this, + callback.value() + ); + } + this->insightWorker.queueTask(readStackPointerTask); } } ); - QObject::connect( - readMemoryTask, - &InsightWorkerTask::finished, - this, - [this] { - this->refreshButton->stopSpin(); - - if (this->targetState == Targets::TargetState::STOPPED) { - this->refreshButton->setDisabled(false); - } - } - ); - - if (callback.has_value()) { + // If we're refreshing RAM, the UI should only be updated once we've retrieved the current stack pointer. + if (this->targetMemoryDescriptor.type != Targets::TargetMemoryType::RAM) { QObject::connect( readMemoryTask, - &InsightWorkerTask::completed, + &InsightWorkerTask::finished, this, - callback.value() + [this] { + this->refreshButton->stopSpin(); + + if (this->targetState == Targets::TargetState::STOPPED) { + this->refreshButton->setDisabled(false); + } + } ); + + if (callback.has_value()) { + QObject::connect( + readMemoryTask, + &InsightWorkerTask::completed, + this, + callback.value() + ); + } } this->insightWorker.queueTask(readMemoryTask);