From 6a8c5688dca49a2e580f95398a07ddf9042fe5a2 Mon Sep 17 00:00:00 2001 From: Nav Date: Wed, 14 Sep 2022 19:01:17 +0100 Subject: [PATCH] Moved byte item selection to std::map, to ensure sorting of byte item pointers by byte item memory address --- .../HexViewerWidget/ByteItemGraphicsScene.cpp | 8 ++++---- .../HexViewerWidget/ByteItemGraphicsScene.hpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp index 20926794..72f4fa4d 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp @@ -673,13 +673,13 @@ namespace Bloom::Widgets void ByteItemGraphicsScene::selectByteItem(ByteItem* byteItem) { byteItem->selected = true; - this->selectedByteItems.insert(byteItem); + this->selectedByteItemsByAddress.insert(std::pair(byteItem->address, byteItem)); byteItem->update(); } void ByteItemGraphicsScene::deselectByteItem(ByteItem* byteItem) { byteItem->selected = false; - this->selectedByteItems.erase(byteItem); + this->selectedByteItemsByAddress.erase(byteItem->address); byteItem->update(); } @@ -693,12 +693,12 @@ namespace Bloom::Widgets } void ByteItemGraphicsScene::clearByteItemSelection() { - for (auto* byteItem : this->selectedByteItems) { + for (const auto& [address, byteItem] : this->selectedByteItemsByAddress) { byteItem->selected = false; byteItem->update(); } - this->selectedByteItems.clear(); + this->selectedByteItemsByAddress.clear(); } void ByteItemGraphicsScene::selectAllByteItems() { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.hpp index b2f0495c..42a7ec99 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.hpp @@ -105,7 +105,7 @@ namespace Bloom::Widgets ByteAddressContainer* byteAddressContainer = nullptr; std::set highlightedByteItems; - std::set selectedByteItems; + std::map selectedByteItemsByAddress; QGraphicsRectItem* rubberBandRectItem = nullptr; std::optional rubberBandInitPoint = std::nullopt;