Mathias Fröhlich:

zero out all parent pointers, else they might be dangling.
This commit is contained in:
ehofman
2006-03-04 12:46:29 +00:00
parent 5b3c5407a1
commit 1cbceec0e1
+6 -1
View File
@@ -250,7 +250,7 @@ compare_strings (const char * s1, const char * s2)
* Locate a child node by name and index. * Locate a child node by name and index.
*/ */
static int static int
find_child (const char * name, int index, vector<SGPropertyNode_ptr> nodes) find_child (const char * name, int index, const vector<SGPropertyNode_ptr>& nodes)
{ {
int nNodes = nodes.size(); int nNodes = nodes.size();
for (int i = 0; i < nNodes; i++) { for (int i = 0; i < nNodes; i++) {
@@ -749,6 +749,11 @@ SGPropertyNode::SGPropertyNode (const char * name,
*/ */
SGPropertyNode::~SGPropertyNode () SGPropertyNode::~SGPropertyNode ()
{ {
// zero out all parent pointers, else they might be dangling
for (unsigned i = 0; i < _children.size(); ++i)
_children[i]->_parent = 0;
for (unsigned i = 0; i < _removedChildren.size(); ++i)
_removedChildren[i]->_parent = 0;
delete _path_cache; delete _path_cache;
clearValue(); clearValue();
delete _listeners; delete _listeners;