From 922812a9133ee3d302de16c5738b23596b11ab2d Mon Sep 17 00:00:00 2001 From: mfranz Date: Fri, 27 Apr 2007 14:30:05 +0000 Subject: [PATCH] make listeners aware of their id, and output trigger message in log levels "debug" and "bulk" --- src/Scripting/NasalSys.cxx | 6 ++++-- src/Scripting/NasalSys.hxx | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx index d897a4f11..70eb70002 100644 --- a/src/Scripting/NasalSys.cxx +++ b/src/Scripting/NasalSys.cxx @@ -689,7 +689,7 @@ naRef FGNasalSys::setListener(naContext c, int argc, naRef* args) bool initial = argc > 2 && naTrue(args[2]); FGNasalListener *nl = new FGNasalListener(node, handler, this, - gcSave(handler)); + gcSave(handler), _listenerId); node->addChangeListener(nl, initial); _listener[_listenerId] = nl; @@ -725,10 +725,11 @@ naRef FGNasalSys::removeListener(naContext c, int argc, naRef* args) // FGNasalListener class. FGNasalListener::FGNasalListener(SGPropertyNode_ptr node, naRef handler, - FGNasalSys* nasal, int key) : + FGNasalSys* nasal, int key, int id) : _node(node), _handler(handler), _gcKey(key), + _id(id), _nas(nasal), _active(0), _dead(false) @@ -747,6 +748,7 @@ void FGNasalListener::valueChanged(SGPropertyNode* node) if(_active || _dead) return; + SG_LOG(SG_NASAL, SG_DEBUG, "trigger listener #" << _id); _active++; _nas->_cmdArg = node; _nas->call(_handler, naNil()); diff --git a/src/Scripting/NasalSys.hxx b/src/Scripting/NasalSys.hxx index ec8cf886e..700b23011 100644 --- a/src/Scripting/NasalSys.hxx +++ b/src/Scripting/NasalSys.hxx @@ -131,7 +131,7 @@ private: class FGNasalListener : public SGPropertyChangeListener { public: FGNasalListener(SGPropertyNode_ptr node, naRef handler, - FGNasalSys* nasal, int key); + FGNasalSys* nasal, int key, int id); ~FGNasalListener(); void valueChanged(SGPropertyNode* node); @@ -141,6 +141,7 @@ private: SGPropertyNode_ptr _node; naRef _handler; int _gcKey; + int _id; FGNasalSys* _nas; unsigned int _active; bool _dead;