Fixed HexViewerItem pointer invalidation bug
This commit is contained in:
@@ -76,6 +76,7 @@ target_sources(
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsView.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsView.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsScene.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsScene.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItem.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/GroupItem.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/GroupItem.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/TopLevelGroupItem.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/TopLevelGroupItem.cpp
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ namespace Bloom::Widgets
|
|||||||
this->setCacheMode(QGraphicsItem::CacheMode::NoCache);
|
this->setCacheMode(QGraphicsItem::CacheMode::NoCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~GraphicsItem() {
|
||||||
|
if (this->hexViewerItem != nullptr) {
|
||||||
|
this->hexViewerItem->allocatedGraphicsItem = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void setHexViewerItem(HexViewerItem* item) {
|
void setHexViewerItem(HexViewerItem* item) {
|
||||||
if (this->hexViewerItem != nullptr) {
|
if (this->hexViewerItem != nullptr) {
|
||||||
this->hexViewerItem->allocatedGraphicsItem = nullptr;
|
this->hexViewerItem->allocatedGraphicsItem = nullptr;
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#include "HexViewerItem.hpp"
|
||||||
|
|
||||||
|
#include "GraphicsItem.hpp"
|
||||||
|
|
||||||
|
namespace Bloom::Widgets
|
||||||
|
{
|
||||||
|
HexViewerItem::HexViewerItem(Targets::TargetMemoryAddress startAddress, HexViewerItem* parent)
|
||||||
|
: startAddress(startAddress)
|
||||||
|
, parent(parent)
|
||||||
|
{}
|
||||||
|
|
||||||
|
HexViewerItem::~HexViewerItem() {
|
||||||
|
if (this->allocatedGraphicsItem != nullptr) {
|
||||||
|
this->allocatedGraphicsItem->setHexViewerItem(nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QPoint HexViewerItem::position() const {
|
||||||
|
if (this->parent != nullptr) {
|
||||||
|
return this->parent->position() + this->relativePosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this->relativePosition;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,23 +25,11 @@ namespace Bloom::Widgets
|
|||||||
HexViewerItem* parent = nullptr;
|
HexViewerItem* parent = nullptr;
|
||||||
GraphicsItem* allocatedGraphicsItem = nullptr;
|
GraphicsItem* allocatedGraphicsItem = nullptr;
|
||||||
|
|
||||||
HexViewerItem(
|
HexViewerItem(Targets::TargetMemoryAddress startAddress, HexViewerItem* parent = nullptr);
|
||||||
Targets::TargetMemoryAddress startAddress,
|
|
||||||
HexViewerItem* parent = nullptr
|
|
||||||
)
|
|
||||||
: startAddress(startAddress)
|
|
||||||
, parent(parent)
|
|
||||||
{};
|
|
||||||
|
|
||||||
virtual ~HexViewerItem() = default;
|
virtual ~HexViewerItem();
|
||||||
|
|
||||||
QPoint position() const {
|
QPoint position() const;
|
||||||
if (this->parent != nullptr) {
|
|
||||||
return this->parent->position() + this->relativePosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this->relativePosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual QSize size() const = 0;
|
virtual QSize size() const = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user