diff options
author | dimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7> | 2000-04-23 18:39:17 (GMT) |
---|---|---|
committer | dimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7> | 2000-04-23 18:39:17 (GMT) |
commit | e2b4a623decf7c8b4435f742f05d07323ad8d6f2 (patch) | |
tree | ae15def425ebe4c6c13d7b4ffd8e147e03d535b3 /src/dot.cpp | |
parent | 0e7fba152ca1c24593a5c9b01460116d16ca3f97 (diff) | |
download | Doxygen-e2b4a623decf7c8b4435f742f05d07323ad8d6f2.zip Doxygen-e2b4a623decf7c8b4435f742f05d07323ad8d6f2.tar.gz Doxygen-e2b4a623decf7c8b4435f742f05d07323ad8d6f2.tar.bz2 |
Release-1.1.2-20000423
Diffstat (limited to 'src/dot.cpp')
-rw-r--r-- | src/dot.cpp | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/src/dot.cpp b/src/dot.cpp index 3c59fd6..f4f5fbc 100644 --- a/src/dot.cpp +++ b/src/dot.cpp @@ -166,6 +166,18 @@ class DotNodeList : public QList<DotNode> //-------------------------------------------------------------------- + +/*! helper function that deletes all nodes in a connected graph, given + * one of the graph's nodes + */ +static void deleteNodes(DotNode *node) +{ + static DotNodeList deletedNodes; + deletedNodes.setAutoDelete(TRUE); + node->deleteNode(deletedNodes); // collect nodes to be deleted. + deletedNodes.clear(); // actually remove the nodes. +} + DotNode::DotNode(int n,const char *lab,const char *url,int distance,bool isRoot) : m_number(n), m_label(lab), m_url(url), m_isRoot(isRoot) { @@ -237,39 +249,32 @@ void DotNode::removeParent(DotNode *n) if (m_parents) m_parents->remove(n); } -void DotNode::deleteNode() +void DotNode::deleteNode(DotNodeList &deletedList) { if (m_deleted) return; // avoid recursive loops in case the graph has cycles m_deleted=TRUE; - if (m_parents!=0) + if (m_parents!=0) // delete all parent nodes of this node { QListIterator<DotNode> dnlip(*m_parents); DotNode *pn; for (dnlip.toFirst();(pn=dnlip.current());++dnlip) { - pn->removeChild(this); - if (!pn->m_deleted) - { - pn->deleteNode(); - } - // do not access pn after this! + //pn->removeChild(this); + pn->deleteNode(deletedList); } } - if (m_children!=0) + if (m_children!=0) // delete all child nodes of this node { QListIterator<DotNode> dnlic(*m_children); DotNode *cn; for (dnlic.toFirst();(cn=dnlic.current());++dnlic) { - cn->removeParent(this); - if (!cn->m_deleted) - { - cn->deleteNode(); - } - // do not access cn after this! + //cn->removeParent(this); + cn->deleteNode(deletedList); } } - delete this; + // add this node to the list of deleted nodes. + deletedList.append(this); } void DotNode::writeBox(QTextStream &t,bool hasNonReachableChildren) @@ -684,7 +689,7 @@ DotGfxHierarchyTable::~DotGfxHierarchyTable() { DotNode *oldNode=n; n=m_rootNodes->next(); - oldNode->deleteNode(); + deleteNodes(oldNode); } delete m_rootNodes; delete m_usedNodes; @@ -792,7 +797,7 @@ bool DotGfxUsageGraph::isTrivial() const DotGfxUsageGraph::~DotGfxUsageGraph() { - m_startNode->deleteNode(); + deleteNodes(m_startNode); delete m_usedNodes; } @@ -1011,7 +1016,7 @@ DotInclDepGraph::DotInclDepGraph(FileDef *fd) DotInclDepGraph::~DotInclDepGraph() { - m_startNode->deleteNode(); + deleteNodes(m_startNode); delete m_usedNodes; } |