Corrected segmentation fault bug caused by QHash iterator invalidation

This commit is contained in:
Nav
2023-04-11 23:06:54 +01:00
parent 73b31fd22b
commit a7dd7d1d52
2 changed files with 5 additions and 5 deletions

View File

@@ -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);

View File

@@ -5,7 +5,7 @@
#include <QResizeEvent>
#include <QShowEvent>
#include <QVBoxLayout>
#include <QHash>
#include <QMap>
#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<FocusedMemoryRegion>& focusedMemoryRegions;
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions;
QHash<QString, MemorySnapshot> snapshotsById;
QHash<QString, MemorySnapshotItem*> snapshotItemsById;
QMap<QString, MemorySnapshot> snapshotsById;
QMap<QString, MemorySnapshotItem*> snapshotItemsById;
QWidget* container = nullptr;
QWidget* toolBar = nullptr;