Moved byte item selection to std::map, to ensure sorting of byte item pointers by byte item memory address

This commit is contained in:
Nav
2022-09-14 19:01:17 +01:00
parent 9aff8183dd
commit 6a8c5688dc
2 changed files with 5 additions and 5 deletions

View File

@@ -673,13 +673,13 @@ namespace Bloom::Widgets
void ByteItemGraphicsScene::selectByteItem(ByteItem* byteItem) { void ByteItemGraphicsScene::selectByteItem(ByteItem* byteItem) {
byteItem->selected = true; byteItem->selected = true;
this->selectedByteItems.insert(byteItem); this->selectedByteItemsByAddress.insert(std::pair(byteItem->address, byteItem));
byteItem->update(); byteItem->update();
} }
void ByteItemGraphicsScene::deselectByteItem(ByteItem* byteItem) { void ByteItemGraphicsScene::deselectByteItem(ByteItem* byteItem) {
byteItem->selected = false; byteItem->selected = false;
this->selectedByteItems.erase(byteItem); this->selectedByteItemsByAddress.erase(byteItem->address);
byteItem->update(); byteItem->update();
} }
@@ -693,12 +693,12 @@ namespace Bloom::Widgets
} }
void ByteItemGraphicsScene::clearByteItemSelection() { void ByteItemGraphicsScene::clearByteItemSelection() {
for (auto* byteItem : this->selectedByteItems) { for (const auto& [address, byteItem] : this->selectedByteItemsByAddress) {
byteItem->selected = false; byteItem->selected = false;
byteItem->update(); byteItem->update();
} }
this->selectedByteItems.clear(); this->selectedByteItemsByAddress.clear();
} }
void ByteItemGraphicsScene::selectAllByteItems() { void ByteItemGraphicsScene::selectAllByteItems() {

View File

@@ -105,7 +105,7 @@ namespace Bloom::Widgets
ByteAddressContainer* byteAddressContainer = nullptr; ByteAddressContainer* byteAddressContainer = nullptr;
std::set<ByteItem*> highlightedByteItems; std::set<ByteItem*> highlightedByteItems;
std::set<ByteItem*> selectedByteItems; std::map<Targets::TargetMemoryAddress, ByteItem*> selectedByteItemsByAddress;
QGraphicsRectItem* rubberBandRectItem = nullptr; QGraphicsRectItem* rubberBandRectItem = nullptr;
std::optional<QPointF> rubberBandInitPoint = std::nullopt; std::optional<QPointF> rubberBandInitPoint = std::nullopt;