Fixed HexViewerItem pointer invalidation bug
This commit is contained in:
@@ -20,6 +20,12 @@ namespace Bloom::Widgets
|
||||
this->setCacheMode(QGraphicsItem::CacheMode::NoCache);
|
||||
}
|
||||
|
||||
~GraphicsItem() {
|
||||
if (this->hexViewerItem != nullptr) {
|
||||
this->hexViewerItem->allocatedGraphicsItem = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void setHexViewerItem(HexViewerItem* item) {
|
||||
if (this->hexViewerItem != 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;
|
||||
GraphicsItem* allocatedGraphicsItem = nullptr;
|
||||
|
||||
HexViewerItem(
|
||||
Targets::TargetMemoryAddress startAddress,
|
||||
HexViewerItem* parent = nullptr
|
||||
)
|
||||
: startAddress(startAddress)
|
||||
, parent(parent)
|
||||
{};
|
||||
HexViewerItem(Targets::TargetMemoryAddress startAddress, HexViewerItem* parent = nullptr);
|
||||
|
||||
virtual ~HexViewerItem() = default;
|
||||
virtual ~HexViewerItem();
|
||||
|
||||
QPoint position() const {
|
||||
if (this->parent != nullptr) {
|
||||
return this->parent->position() + this->relativePosition;
|
||||
}
|
||||
|
||||
return this->relativePosition;
|
||||
}
|
||||
QPoint position() const;
|
||||
|
||||
virtual QSize size() const = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user