From a7dd7d1d5281f4fe9689ae0bf067df880cd58ad7 Mon Sep 17 00:00:00 2001 From: Nav Date: Tue, 11 Apr 2023 23:06:54 +0100 Subject: [PATCH] Corrected segmentation fault bug caused by QHash iterator invalidation --- .../SnapshotManager/SnapshotManager.cpp | 4 ++-- .../SnapshotManager/SnapshotManager.hpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.cpp index 3f8ee556..bfc20218 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.cpp @@ -174,10 +174,10 @@ namespace Bloom::Widgets } void SnapshotManager::addSnapshot(MemorySnapshot&& snapshotTmp) { - const auto snapshotIt = this->snapshotsById.emplace(snapshotTmp.id, std::move(snapshotTmp)); + const auto snapshotIt = this->snapshotsById.insert(snapshotTmp.id, std::move(snapshotTmp)); const auto& snapshot = *snapshotIt; - const auto snapshotItemIt = this->snapshotItemsById.emplace(snapshot.id, new MemorySnapshotItem(snapshot)); + const auto snapshotItemIt = this->snapshotItemsById.insert(snapshot.id, new MemorySnapshotItem(snapshot)); auto& snapshotItem = *snapshotItemIt; this->snapshotListScene->addListItem(snapshotItem); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.hpp index 5e1f8379..e22237a5 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include "src/Insight/UserInterfaces/InsightWindow/Widgets/PaneWidget.hpp" #include "src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp" @@ -56,8 +56,8 @@ namespace Bloom::Widgets const std::vector& focusedMemoryRegions; const std::vector& excludedMemoryRegions; - QHash snapshotsById; - QHash snapshotItemsById; + QMap snapshotsById; + QMap snapshotItemsById; QWidget* container = nullptr; QWidget* toolBar = nullptr;