From: James Turner Date: Tue, 3 Dec 2013 21:38:24 +0000 (+0000) Subject: Reset: free nasal-module-listeners on shutdown. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9c11dfd545e466d863c7aac2b4dd18328b1e5360;p=flightgear.git Reset: free nasal-module-listeners on shutdown. --- diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx index 57967ebf6..16a2699da 100644 --- a/src/Scripting/NasalSys.cxx +++ b/src/Scripting/NasalSys.cxx @@ -826,6 +826,11 @@ void FGNasalSys::shutdown() } _commands.clear(); + std::vector::iterator k = _moduleListeners.begin(); + for(; k!= _moduleListeners.end(); ++k) + delete *k; + _moduleListeners.clear(); + naClearSaved(); _string = naNil(); // will be freed by _context @@ -1007,6 +1012,7 @@ void FGNasalSys::loadPropertyScripts(SGPropertyNode* n) if (enable) { FGNasalModuleListener* listener = new FGNasalModuleListener(n); + _moduleListeners.push_back(listener); enable->addChangeListener(listener, false); } } diff --git a/src/Scripting/NasalSys.hxx b/src/Scripting/NasalSys.hxx index f8be35db1..d4680f139 100644 --- a/src/Scripting/NasalSys.hxx +++ b/src/Scripting/NasalSys.hxx @@ -22,6 +22,7 @@ class FGNasalListener; class SGCondition; class FGNasalModelData; class NasalCommand; +class FGNasalModuleListener; namespace simgear { class BufferedLogCallback; } @@ -159,6 +160,8 @@ private: std::map _listener; std::vector _dead_listener; + std::vector _moduleListeners; + static int _listenerId; void loadPropertyScripts();