]> git.mxchange.org Git - flightgear.git/commitdiff
- remove listener in ~FGNasalListener(), not FGNasalSys::removelistener
authormfranz <mfranz>
Sat, 10 Jun 2006 22:21:22 +0000 (22:21 +0000)
committermfranz <mfranz>
Sat, 10 Jun 2006 22:21:22 +0000 (22:21 +0000)
- delete all listeners in ~FGNasalSys()

src/Scripting/NasalSys.cxx

index 9b9eb5a29ccda53dbd2dc525b47b9ea30d277373..721614da7df6f1c6bc86417540ce2b71103b4636 100644 (file)
@@ -60,6 +60,10 @@ FGNasalSys::FGNasalSys()
 
 FGNasalSys::~FGNasalSys()
 {
+    map<int, FGNasalListener *>::iterator it, end = _listener.end();
+    for (it = _listener.begin(); it != end; ++it)
+        delete it->second;
+
     // Nasal doesn't have a "destroy context" API yet. :(
     // Not a problem for a global subsystem that will never be
     // destroyed.  And the context is actually a global, so no memory
@@ -679,7 +683,6 @@ naRef FGNasalSys::removeListener(int argc, naRef* args)
         return naNil();
 
     FGNasalListener *nl = _listener[i];
-    nl->_node->removeChangeListener(nl);
     _listener.erase(i);
     delete nl;
     return naNum(_listener.size());
@@ -701,6 +704,7 @@ FGNasalListener::FGNasalListener(SGPropertyNode_ptr node, naRef handler,
 
 FGNasalListener::~FGNasalListener()
 {
+    _node->removeChangeListener(this);
     _nas->gcRelease(_gcKey);
 }