Changeset 5296 in orxonox.OLD for trunk/src/lib/coord
- Timestamp:
- Oct 7, 2005, 10:42:22 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/coord/p_node.cc
r5255 r5296 74 74 75 75 /** 76 * standard deconstructor 77 */ 76 * standard deconstructor 77 * 78 * There are two general ways to delete a PNode 79 * 1. delete instance; 80 * -> result 81 * delete this Node and all its children and children's children... 82 * (danger if you still need the children's instance somewhere else!!) 83 * 84 * 2. instance->remove2D(); delete instance; 85 * -> result: 86 * moves its children to the NullParent 87 * then deletes the Element. 88 */ 78 89 PNode::~PNode () 79 90 { 80 if (this->parent) 81 this->parent->removeChild(this); 82 else 83 { 84 tIterator<PNode>* iterator = this->children->getIterator(); 85 PNode* pn = iterator->firstElement(); 86 while( pn != NULL) 87 { 88 delete pn; 89 pn = iterator->nextElement(); 90 } 91 delete iterator; 92 /* this deletes all children in the list */ 91 // remove the Node, delete it's children. 92 tIterator<PNode>* iterator = this->children->getIterator(); 93 PNode* child = iterator->firstElement(); 94 95 while( child != NULL) 96 { 97 delete child; 98 child = iterator->nextElement(); 99 } 100 delete iterator; 101 102 if (this->parent != NULL) 103 { 104 this->parent->children->remove(this); 105 this->parent = NULL; 93 106 } 94 107 delete this->children; 108 109 // remove all other allocated memory. 95 110 if (this->toCoordinate != NULL) 96 111 delete this->toCoordinate; … … 98 113 delete this->toDirection; 99 114 } 115 100 116 101 117 /**
Note: See TracChangeset
for help on using the changeset viewer.