Skip to content
Snippets Groups Projects
Commit 00be5a2b authored by Matthias Puchner's avatar Matthias Puchner
Browse files

add unlink possibility to IView

parent 5d24b5ef
No related branches found
No related tags found
1 merge request!250Fix issue36 item deletion
...@@ -24,8 +24,7 @@ IView::IView(QGraphicsItem* parent) : QGraphicsObject(parent), m_item(nullptr) ...@@ -24,8 +24,7 @@ IView::IView(QGraphicsItem* parent) : QGraphicsObject(parent), m_item(nullptr)
IView::~IView() IView::~IView()
{ {
if (m_item) unlinkFromItem();
m_item->mapper()->unsubscribe(this);
} }
void IView::setParameterizedItem(SessionGraphicsItem* item) void IView::setParameterizedItem(SessionGraphicsItem* item)
...@@ -52,6 +51,13 @@ void IView::setParameterizedItem(SessionGraphicsItem* item) ...@@ -52,6 +51,13 @@ void IView::setParameterizedItem(SessionGraphicsItem* item)
void IView::addView(IView*, int) {} void IView::addView(IView*, int) {}
void IView::unlinkFromItem()
{
if (m_item)
m_item->mapper()->unsubscribe(this);
m_item = nullptr;
}
void IView::onChangedX() void IView::onChangedX()
{ {
if (!m_item) if (!m_item)
......
...@@ -36,6 +36,10 @@ public: ...@@ -36,6 +36,10 @@ public:
virtual void addView(IView* childView, int row = 0); virtual void addView(IView* childView, int row = 0);
//! Call this in case you call deleteLater() for the view and the
//! linked item itself may not exist any more at the time of deletion
void unlinkFromItem();
signals: signals:
void aboutToBeDeleted(); void aboutToBeDeleted();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment