]> git.mxchange.org Git - flightgear.git/blobdiff - src/Scripting/NasalSys.cxx
Don't restore initial screen geometry because there is nothing in fg_os* to resize...
[flightgear.git] / src / Scripting / NasalSys.cxx
index 4f3d1f36acf3fb6ef65e2e88bb016200039d5bd9..c0b25c4eaf47377baa79a1279da23315840800ef 100644 (file)
@@ -674,6 +674,45 @@ naRef FGNasalSys::removeListener(int argc, naRef* args)
 
 
 
+// FGNasalListener class.
+
+FGNasalListener::FGNasalListener(SGPropertyNode_ptr node, naRef handler,
+                                 FGNasalSys* nasal, int key) :
+    _node(node),
+    _handler(handler),
+    _gcKey(key),
+    _nas(nasal),
+    _active(0)
+{
+}
+
+FGNasalListener::~FGNasalListener()
+{
+    _nas->gcRelease(_gcKey);
+}
+
+void FGNasalListener::valueChanged(SGPropertyNode* node)
+{
+    if (_active) {
+        SG_LOG(SG_NASAL, SG_ALERT, "Recursive listener call "
+                "on property " << node->getPath());
+        return;
+    }
+    _active++;
+    _nas->_cmdArg = node;
+    naContext c = naNewContext();
+    naModUnlock();
+    naCall(c, _handler, 0, 0, naNil(), naNil());
+    naModLock();
+    if(naGetError(c))
+        _nas->logError(c);
+    naFreeContext(c);
+    _active--;
+}
+
+
+
+
 // FGNasalModelData class.  If sgLoad3DModel() is called with a pointer to
 // such a class, then it lets modelLoaded() run the <load> script, and the
 // destructor the <unload> script. The latter happens when the model branch