Refresh snapshot diff windows when comparing against current memory and the memory has been updated

This commit is contained in:
Nav
2023-05-01 17:08:06 +01:00
parent 9c8e130446
commit e72efe71f2
5 changed files with 56 additions and 7 deletions

View File

@@ -82,6 +82,25 @@ namespace Bloom::Widgets
this->dataBSecondaryLabel->setVisible(false);
}
void SnapshotDiff::refreshB(
Targets::TargetMemoryBuffer data,
std::vector<FocusedMemoryRegion> focusedRegions,
std::vector<ExcludedMemoryRegion> excludedRegions,
Targets::TargetStackPointer stackPointer
) {
this->hexViewerDataB = data;
this->focusedRegionsB = focusedRegions;
this->excludedRegionsB = excludedRegions;
this->stackPointerB = stackPointer;
if (this->memoryDescriptor.type == Targets::TargetMemoryType::RAM) {
this->hexViewerWidgetB->setStackPointer(this->stackPointerB);
}
this->hexViewerWidgetB->refreshRegions();
this->hexViewerWidgetB->updateValues();
}
void SnapshotDiff::showEvent(QShowEvent* event) {
QWidget::showEvent(event);
}

View File

@@ -45,6 +45,13 @@ namespace Bloom::Widgets
QWidget* parent = nullptr
);
void refreshB(
Targets::TargetMemoryBuffer data,
std::vector<FocusedMemoryRegion> focusedRegions,
std::vector<ExcludedMemoryRegion> excludedRegions,
Targets::TargetStackPointer stackPointer
);
protected:
void showEvent(QShowEvent* event) override;
void resizeEvent(QResizeEvent* event) override;

View File

@@ -239,6 +239,24 @@ namespace Bloom::Widgets
this->show();
}
void SnapshotManager::onCurrentDataChanged() {
this->createSnapshotWindow->refreshForm();
if (!this->data.has_value()) {
return;
}
// Refresh the data in all snapshot diff windows where current data is being used
for (auto& snapshotCurrentDiff : this->snapshotCurrentDiffsBySnapshotAId) {
snapshotCurrentDiff->refreshB(
*(this->data),
this->focusedMemoryRegions,
this->excludedMemoryRegions,
this->stackPointer.value_or(0)
);
}
}
void SnapshotManager::resizeEvent(QResizeEvent* event) {
const auto size = this->size();
this->container->setFixedSize(size.width(), size.height());
@@ -360,18 +378,17 @@ namespace Bloom::Widgets
return;
}
const auto diffKey = snapshotIdA;
auto snapshotDiffIt = this->snapshotDiffs.find(diffKey);
auto snapshotDiffIt = this->snapshotCurrentDiffsBySnapshotAId.find(snapshotIdA);
if (snapshotDiffIt == this->snapshotDiffs.end()) {
if (snapshotDiffIt == this->snapshotCurrentDiffsBySnapshotAId.end()) {
const auto& snapshotItA = this->snapshotsById.find(snapshotIdA);
if (snapshotItA == this->snapshotsById.end()) {
return;
}
snapshotDiffIt = this->snapshotDiffs.insert(
diffKey,
snapshotDiffIt = this->snapshotCurrentDiffsBySnapshotAId.insert(
snapshotIdA,
new SnapshotDiff(
snapshotItA.value(),
*(this->data),

View File

@@ -46,6 +46,8 @@ namespace Bloom::Widgets
PanelWidget* parent = nullptr
);
void onCurrentDataChanged();
signals:
void insightWorkerTaskCreated(const QSharedPointer<InsightWorkerTask>& task);
void snapshotRestored(const QString& snapshotId);
@@ -69,6 +71,7 @@ namespace Bloom::Widgets
QMap<QString, MemorySnapshotItem*> snapshotItemsById;
QMap<QString, SnapshotViewer*> snapshotViewersById;
QMap<QString, SnapshotDiff*> snapshotDiffs;
QMap<QString, SnapshotDiff*> snapshotCurrentDiffsBySnapshotAId;
QWidget* container = nullptr;
QWidget* toolBar = nullptr;

View File

@@ -361,6 +361,8 @@ namespace Bloom::Widgets
&InsightWorkerTask::finished,
this,
[this] {
this->snapshotManager->onCurrentDataChanged();
this->refreshButton->stopSpin();
if (this->targetState == Targets::TargetState::STOPPED) {
@@ -380,6 +382,9 @@ namespace Bloom::Widgets
this->taskProgressIndicator->addTask(readStackPointerTask);
InsightWorker::queueTask(readStackPointerTask);
} else {
this->snapshotManager->onCurrentDataChanged();
}
}
);
@@ -580,8 +585,6 @@ namespace Bloom::Widgets
this->data = data;
this->hexViewerWidget->updateValues();
this->setStaleData(false);
this->snapshotManager->createSnapshotWindow->refreshForm();
}
void TargetMemoryInspectionPane::openMemoryRegionManagerWindow() {