Fixed bug with copying byte addresses/values from hex viewer to clipboard - they were being copied in an incorrect order
This commit is contained in:
@@ -5,6 +5,8 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
#include <map>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "src/Insight/InsightWorker/InsightWorker.hpp"
|
#include "src/Insight/InsightWorker/InsightWorker.hpp"
|
||||||
#include "src/Insight/InsightSignals.hpp"
|
#include "src/Insight/InsightSignals.hpp"
|
||||||
@@ -730,6 +732,20 @@ namespace Bloom::Widgets
|
|||||||
this->byteAddressContainer->invalidateChildItemCaches();
|
this->byteAddressContainer->invalidateChildItemCaches();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map<Targets::TargetMemoryAddress, ByteItem*> ItemGraphicsScene::sortedByteItemsByAddress() {
|
||||||
|
auto sortedByteItemsByAddress = std::map<Targets::TargetMemoryAddress, ByteItem*>();
|
||||||
|
std::transform(
|
||||||
|
this->selectedByteItemsByAddress.begin(),
|
||||||
|
this->selectedByteItemsByAddress.end(),
|
||||||
|
std::inserter(sortedByteItemsByAddress, sortedByteItemsByAddress.end()),
|
||||||
|
[] (const decltype(this->selectedByteItemsByAddress)::value_type& pair) {
|
||||||
|
return pair;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return sortedByteItemsByAddress;
|
||||||
|
}
|
||||||
|
|
||||||
void ItemGraphicsScene::copyAddressesToClipboard(AddressType type) {
|
void ItemGraphicsScene::copyAddressesToClipboard(AddressType type) {
|
||||||
if (this->selectedByteItemsByAddress.empty()) {
|
if (this->selectedByteItemsByAddress.empty()) {
|
||||||
return;
|
return;
|
||||||
@@ -738,7 +754,7 @@ namespace Bloom::Widgets
|
|||||||
auto data = QString();
|
auto data = QString();
|
||||||
const auto memoryStartAddress = this->state.memoryDescriptor.addressRange.startAddress;
|
const auto memoryStartAddress = this->state.memoryDescriptor.addressRange.startAddress;
|
||||||
|
|
||||||
for (const auto& [address, byteItem] : this->selectedByteItemsByAddress) {
|
for (const auto& [address, byteItem] : this->sortedByteItemsByAddress()) {
|
||||||
data.append(
|
data.append(
|
||||||
"0x" + QString::number(
|
"0x" + QString::number(
|
||||||
type == AddressType::RELATIVE
|
type == AddressType::RELATIVE
|
||||||
@@ -759,7 +775,7 @@ namespace Bloom::Widgets
|
|||||||
|
|
||||||
auto data = QString();
|
auto data = QString();
|
||||||
|
|
||||||
for (const auto& [address, byteItem] : this->selectedByteItemsByAddress) {
|
for (const auto& [address, byteItem] : this->sortedByteItemsByAddress()) {
|
||||||
const unsigned char byteValue = byteItem->excluded
|
const unsigned char byteValue = byteItem->excluded
|
||||||
? 0x00
|
? 0x00
|
||||||
: (*this->state.data)[byteItem->startAddress - this->state.memoryDescriptor.addressRange.startAddress];
|
: (*this->state.data)[byteItem->startAddress - this->state.memoryDescriptor.addressRange.startAddress];
|
||||||
@@ -776,7 +792,7 @@ namespace Bloom::Widgets
|
|||||||
|
|
||||||
auto data = QString();
|
auto data = QString();
|
||||||
|
|
||||||
for (const auto& [address, byteItem] : this->selectedByteItemsByAddress) {
|
for (const auto& [address, byteItem] : this->sortedByteItemsByAddress()) {
|
||||||
const unsigned char byteValue = byteItem->excluded
|
const unsigned char byteValue = byteItem->excluded
|
||||||
? 0x00
|
? 0x00
|
||||||
: (*this->state.data)[byteItem->startAddress - this->state.memoryDescriptor.addressRange.startAddress];
|
: (*this->state.data)[byteItem->startAddress - this->state.memoryDescriptor.addressRange.startAddress];
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ namespace Bloom::Widgets
|
|||||||
void clearByteItemSelection();
|
void clearByteItemSelection();
|
||||||
void selectAllByteItems();
|
void selectAllByteItems();
|
||||||
void setAddressType(AddressType type);
|
void setAddressType(AddressType type);
|
||||||
|
std::map<Targets::TargetMemoryAddress, ByteItem*> sortedByteItemsByAddress();
|
||||||
void copyAddressesToClipboard(AddressType type);
|
void copyAddressesToClipboard(AddressType type);
|
||||||
void copyHexValuesToClipboard();
|
void copyHexValuesToClipboard();
|
||||||
void copyDecimalValuesToClipboard();
|
void copyDecimalValuesToClipboard();
|
||||||
|
|||||||
Reference in New Issue
Block a user