]> git.mxchange.org Git - flightgear.git/blobdiff - src/Scripting/NasalSys.hxx
- disallow listener re-entry to prevent crash/runaway process
[flightgear.git] / src / Scripting / NasalSys.hxx
index 669b26eea68f82f5de0fbd5ae7a31836d46d02bc..0b10ad0c7f20e191dd5bdeb90587ee0a33c3d5a0 100644 (file)
@@ -4,6 +4,7 @@
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/structure/subsystem_mgr.hxx>
 #include <simgear/nasal/nasal.h>
+#include <simgear/scene/model/model.hxx>
 
 #include <map>
 SG_USING_STD(map);
@@ -125,23 +126,10 @@ private:
 class FGNasalListener : public SGPropertyChangeListener {
 public:
     FGNasalListener(SGPropertyNode_ptr node, naRef handler,
-            FGNasalSys* nasal, int key)
-        : _node(node), _handler(handler), _gcKey(key), _nas(nasal) {}
+                    FGNasalSys* nasal, int key);
 
-    ~FGNasalListener() {
-        _nas->gcRelease(_gcKey);
-    }
-
-    void valueChanged(SGPropertyNode* node) {
-        _nas->_cmdArg = node;
-        naContext c = naNewContext();
-        naModUnlock();
-        naCall(c, _handler, 0, 0, naNil(), naNil());
-        naModLock();
-        if(naGetError(c))
-            _nas->logError(c);
-        naFreeContext(c);
-    }
+    ~FGNasalListener();
+    void valueChanged(SGPropertyNode* node);
 
 private:
     friend class FGNasalSys;
@@ -149,6 +137,19 @@ private:
     naRef _handler;
     int _gcKey;
     FGNasalSys* _nas;
+    bool _active;
+};
+
+
+class FGNasalModelData : public SGModelData {
+public:
+    FGNasalModelData() : _unload(0) {}
+    ~FGNasalModelData();
+    void modelLoaded(const string& path, SGPropertyNode *prop, ssgBranch *);
+
+private:
+    string _module;
+    SGConstPropertyNode_ptr _unload;
 };
 
 #endif // __NASALSYS_HXX