]> git.mxchange.org Git - flightgear.git/blobdiff - src/Scripting/NasalSys.hxx
- fix two bugs
[flightgear.git] / src / Scripting / NasalSys.hxx
index c4acd37b73d881aa3b171ab7af7275147369ed9f..ca7d9f2eaa23d57ae5511f42de3a8263c2303cd4 100644 (file)
@@ -6,8 +6,6 @@
 #include <simgear/nasal/nasal.h>
 #include <simgear/scene/model/model.hxx>
 
-#include <Main/globals.hxx>
-
 #include <map>
 SG_USING_STD(map);
 
@@ -55,7 +53,7 @@ public:
     virtual bool handleCommand(const SGPropertyNode* arg);
 
     void createModule(const char* moduleName, const char* fileName,
-                    const char* src, int len);
+                    const char* src, int len, const SGPropertyNode* arg=0);
 
     void deleteModule(const char* moduleName);
 
@@ -98,7 +96,7 @@ private:
     naContext _context;
     naRef _globals;
 
-    SGPropertyNode* _cmdArg;
+    SGPropertyNode_ptr _cmdArg;
 
     int _nextGCKey;
     naRef _gcHash;
@@ -128,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) {}
-
-    ~FGNasalListener() {
-        _nas->gcRelease(_gcKey);
-    }
+                    FGNasalSys* nasal, int key);
 
-    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;
@@ -152,6 +137,7 @@ private:
     naRef _handler;
     int _gcKey;
     FGNasalSys* _nas;
+    unsigned int _active;
 };
 
 
@@ -163,7 +149,7 @@ public:
 
 private:
     string _module;
-    SGPropertyNode_ptr _unload;
+    SGConstPropertyNode_ptr _unload;
 };
 
 #endif // __NASALSYS_HXX