Edge does not call back in dtor to Node, Node calls the removeEdgeFromList in time

master
Denes Matetelki 14 years ago
parent e3b36decc3
commit e4a24126f9

@ -11,7 +11,6 @@ class Edge : public QGraphicsItem
public:
Edge(Node *sourceNode, Node *destNode);
~Edge();
Node *sourceNode() const;
Node *destNode() const;

@ -6,7 +6,7 @@ TRANSLATIONS = lang/qtmindmap_hu.ts \
qmfiles = .qm/i18n/qtmindmap_hu.qm \
.qm/i18n/qtmindmap_nb_NO.qm
system(mkdir -p .qm/i18n && touch $${qmfiles})
system(mkdir -p .qm/i18n)
isEmpty(QMAKE_LRELEASE)

@ -26,12 +26,6 @@ Edge::Edge(Node *sourceNode, Node *destNode)
adjust();
}
Edge::~Edge()
{
m_sourceNode->removeEdgeFromList(this);
m_destNode->removeEdgeFromList(this);
}
Node * Edge::sourceNode() const
{
return m_sourceNode;

@ -37,7 +37,13 @@ Node::Node(GraphWidget *parent) :
Node::~Node()
{
// dtor of Edge will call removeEdgeFromList on booth nodes.
foreach (EdgeElement element, m_edgeList) delete element.edge;
foreach (EdgeElement element, m_edgeList)
{
Edge *tmp = element.edge;
tmp->sourceNode()->removeEdgeFromList(tmp);
tmp->destNode()->removeEdgeFromList(tmp);
delete tmp;
}
}
void Node::addEdge(Edge *edge, bool startsFromThisNode)
@ -56,7 +62,10 @@ void Node::deleteEdge(Node *otherEnd)
|| (it->edge->sourceNode() == this &&
it->edge->destNode() == otherEnd))
{
delete it->edge;
Edge *tmp = it->edge;
tmp->sourceNode()->removeEdgeFromList(tmp);
tmp->destNode()->removeEdgeFromList(tmp);
delete tmp;
return;
}
}

Loading…
Cancel
Save