]> git.mxchange.org Git - simgear.git/blobdiff - simgear/props/props.cxx
Modified Files:
[simgear.git] / simgear / props / props.cxx
index 722dfee93b2b3e91b5e961a730a280a71c528dec..3ce2687da62d906a14f56e7a877024c78765432e 100644 (file)
@@ -756,7 +756,13 @@ SGPropertyNode::~SGPropertyNode ()
     _removedChildren[i]->_parent = 0;
   delete _path_cache;
   clearValue();
-  delete _listeners;
+
+  if (_listeners) {
+    vector<SGPropertyChangeListener*>::iterator it;
+    for (it = _listeners->begin(); it != _listeners->end(); ++it)
+      (*it)->unregister_property(this);
+    delete _listeners;
+  }
 }
 
 
@@ -2280,12 +2286,8 @@ SGPropertyNode::hash_table::hashcode (const char * key)
 
 SGPropertyChangeListener::~SGPropertyChangeListener ()
 {
-                               // This will come back and remove
-                               // the current item each time.  Is
-                               // that OK?
-  vector<SGPropertyNode *>::iterator it;
-  for (it = _properties.begin(); it != _properties.end(); it++)
-    (*it)->removeChangeListener(this);
+  for (int i = _properties.size() - 1; i >= 0; i--)
+    _properties[i]->removeChangeListener(this);
 }
 
 void