2011/2/5 ThorstenB <bre...@gmail.com>:
> On 05.02.2011 16:21, ThorstenB wrote:
>>
>> I'm currently testing a different patch for the same issue: instead of
>> untieing all properties below the /fdm/jsbsim (only), I added a list
>> to JSBSim's FGPropertyManagager, so it keeps track of all the
>> properties it has actually bound. It can then use this list to untie
>> all its properties - no matter where these are located in the
>> property tree.
>>
>
> New patch pushed to flightgear/next:
> http://www.gitorious.org/fg/flightgear/commit/ad8d46ba648263630b8777c53f852b75cad7ecdd
>
> This will be overwritten by the next JSBSim update, however it's a
> short-term fix and candidate for our pending 2.2 release.
> So, please test if you still see reset issues with JSBSim aircraft. If
> we find it's an improvement (maybe/hopefully the final fix for this
> issue), then we'll be pushing this to the 2.2 branch also. But remember,
> none of the reset fixes is part of the 2.2 branch just yet.
>
> The long term fix needs to be part of the JSBSim repository of course.
> Jon, Erik: please check if you want to use this patch or have some other
> solution to the problem.
>

Hi Thorsten,

Good catch ! I had a quick look at your patch and have a couple of
comments on it :

* Some templates of the Tie() method are located in
FGPropertyManager.h and have been overlooked in your patch (this is
quite important because it leaves a hole in the bottom of which some
bugs may have stayed hidden)
* I would only add the successfully tied properties to the
tied_properties list. In your patch the name of the properties are
unconditionally added to the list. I don't think that does any harm
but the code now looks cleaner to me.
* The method FGFDMExec::checkTied() is now redundant with
FGPropertyManager::Unbind() so the former has been removed in favour
of the latter (this one is rather internal JSBSim stuff, I have
included it for the sake of completeness).
* I would rather make tied_properties a list of SGPropertyNode* rather
than a list of strings (same as above : internal JSBSim stuff)
* Traditionally, method names in JSBSim have the first letter of their
name capitalized (very very minor this one !)

Attached patch includes all the above suggestions. The patch has been
made against the last revision of the 'next' branch of git.

Wow ! This issue is really hard to fix. However it exemplifies the
Open Source model superiority in allowing such a team work to fix
quite a reluctant and annoying bug.

Cheers,

Bertrand.
diff --git a/src/FDM/JSBSim/FGFDMExec.cpp b/src/FDM/JSBSim/FGFDMExec.cpp
index b3b7003..ade4209 100644
--- a/src/FDM/JSBSim/FGFDMExec.cpp
+++ b/src/FDM/JSBSim/FGFDMExec.cpp
@@ -78,22 +78,6 @@ static const char *IdHdr = ID_FDMEXEC;
 CLASS IMPLEMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-void checkTied ( FGPropertyManager *node )
-{
-  int N = node->nChildren();
-  string name;
-
-  for (int i=0; i<N; i++) {
-    if (node->getChild(i)->nChildren() ) {
-      checkTied( (FGPropertyManager*)node->getChild(i) );
-    }
-    if ( node->getChild(i)->isTied() ) {
-      name = ((FGPropertyManager*)node->getChild(i))->GetFullyQualifiedName();
-      node->Untie(name);
-    }
-  }
-}
-
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 // Constructor
 
@@ -185,7 +169,7 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root)
 FGFDMExec::~FGFDMExec()
 {
   try {
-    checkTied( instance );
+    Unbind();
     DeAllocate();
     
     if (IdFDM == 0) { // Meaning this is no child FDM
diff --git a/src/FDM/JSBSim/FGFDMExec.h b/src/FDM/JSBSim/FGFDMExec.h
index c1038c4..b982654 100644
--- a/src/FDM/JSBSim/FGFDMExec.h
+++ b/src/FDM/JSBSim/FGFDMExec.h
@@ -227,7 +227,7 @@ public:
   ~FGFDMExec();
 
   /** Unbind all tied JSBSim properties. */
-  void unbind(void) {instance->unbind();}
+  void Unbind(void) {instance->Unbind();}
 
   /** This routine places a model into the runlist at the specified rate. The
       "rate" is not really a clock rate. It represents how many calls to the
diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx
index 0cc0025..b1daa9c 100644
--- a/src/FDM/JSBSim/JSBSim.cxx
+++ b/src/FDM/JSBSim/JSBSim.cxx
@@ -424,7 +424,7 @@ void FGJSBsim::init()
 
 void FGJSBsim::unbind()
 {
-  fdmex->unbind();
+  fdmex->Unbind();
   FGInterface::unbind();
 }
 
diff --git a/src/FDM/JSBSim/input_output/FGPropertyManager.cpp b/src/FDM/JSBSim/input_output/FGPropertyManager.cpp
index 899565e..01f269b 100755
--- a/src/FDM/JSBSim/input_output/FGPropertyManager.cpp
+++ b/src/FDM/JSBSim/input_output/FGPropertyManager.cpp
@@ -49,16 +49,16 @@ COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
 namespace JSBSim {
 
 bool FGPropertyManager::suppress_warning = true;
-std::vector<std::string> FGPropertyManager::tied_properties;
+std::vector<SGPropertyNode*> FGPropertyManager::tied_properties;
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGPropertyManager::unbind(void)
+void FGPropertyManager::Unbind(void)
 {
-    vector<string>::iterator it;
+    vector<SGPropertyNode*>::iterator it;
     for (it = tied_properties.begin();it < tied_properties.end();it++)
     {
-        Untie(*it);
+        (*it)->untie();
     }
     tied_properties.clear();
 }
@@ -314,11 +314,12 @@ void FGPropertyManager::Untie (const string &name)
 
 void FGPropertyManager::Tie (const string &name, bool *pointer, bool useDefault)
 {
-  tied_properties.push_back(name);
   if (!tie(name.c_str(), SGRawValuePointer<bool>(pointer), useDefault))
     cerr << "Failed to tie property " << name << " to a pointer" << endl;
-  else if (debug_lvl & 0x20)
-    cout << name << endl;
+  else {
+    tied_properties.push_back(getNode(name));
+    if (debug_lvl & 0x20) std::cout << name << std::endl;
+  }
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -326,11 +327,12 @@ void FGPropertyManager::Tie (const string &name, bool *pointer, bool useDefault)
 void FGPropertyManager::Tie (const string &name, int *pointer,
                                           bool useDefault )
 {
-  tied_properties.push_back(name);
   if (!tie(name.c_str(), SGRawValuePointer<int>(pointer), useDefault))
     cerr << "Failed to tie property " << name << " to a pointer" << endl;
-  else if (debug_lvl & 0x20)
-    cout << name << endl;
+  else {
+    tied_properties.push_back(getNode(name));
+    if (debug_lvl & 0x20) std::cout << name << std::endl;
+  }
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -338,11 +340,12 @@ void FGPropertyManager::Tie (const string &name, int *pointer,
 void FGPropertyManager::Tie (const string &name, long *pointer,
                                           bool useDefault )
 {
-  tied_properties.push_back(name);
   if (!tie(name.c_str(), SGRawValuePointer<long>(pointer), useDefault))
     cerr << "Failed to tie property " << name << " to a pointer" << endl;
-  else if (debug_lvl & 0x20)
-    cout << name << endl;
+  else {
+    tied_properties.push_back(getNode(name));
+    if (debug_lvl & 0x20) std::cout << name << std::endl;
+  }
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -350,22 +353,24 @@ void FGPropertyManager::Tie (const string &name, long *pointer,
 void FGPropertyManager::Tie (const string &name, float *pointer,
                                           bool useDefault )
 {
-  tied_properties.push_back(name);
   if (!tie(name.c_str(), SGRawValuePointer<float>(pointer), useDefault))
     cerr << "Failed to tie property " << name << " to a pointer" << endl;
-  else if (debug_lvl & 0x20)
-    cout << name << endl;
+  else {
+    tied_properties.push_back(getNode(name));
+    if (debug_lvl & 0x20) std::cout << name << std::endl;
+  }
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 void FGPropertyManager::Tie (const string &name, double *pointer, bool useDefault)
 {
-  tied_properties.push_back(name);
   if (!tie(name.c_str(), SGRawValuePointer<double>(pointer), useDefault))
     cerr << "Failed to tie property " << name << " to a pointer" << endl;
-  else if (debug_lvl & 0x20)
-    cout << name << endl;
+  else {
+    tied_properties.push_back(getNode(name));
+    if (debug_lvl & 0x20) std::cout << name << std::endl;
+  }
 }
 
 } // namespace JSBSim
diff --git a/src/FDM/JSBSim/input_output/FGPropertyManager.h b/src/FDM/JSBSim/input_output/FGPropertyManager.h
index 54ea918..fd368e5 100644
--- a/src/FDM/JSBSim/input_output/FGPropertyManager.h
+++ b/src/FDM/JSBSim/input_output/FGPropertyManager.h
@@ -77,7 +77,7 @@ class FGPropertyManager : public SGPropertyNode, public FGJSBBase
 {
   private:
     static bool suppress_warning;
-    static std::vector<std::string> tied_properties;
+    static std::vector<SGPropertyNode*> tied_properties;
   public:
     /// Constructor
     FGPropertyManager(void) {suppress_warning = false;}
@@ -406,7 +406,7 @@ class FGPropertyManager : public SGPropertyNode, public FGJSBBase
      * Classes should use this function to release control of any
      * properties they have bound using this property manager.
      */
-    void unbind (void);
+    void Unbind (void);
 
         // Templates cause ambiguity here
 
@@ -534,8 +534,10 @@ class FGPropertyManager : public SGPropertyNode, public FGJSBBase
     {
       if (!tie(name.c_str(), SGRawValueFunctions<V>(getter, setter), useDefault))
         std::cout << "Failed to tie property " << name << " to functions" << std::endl;
-      else if (debug_lvl & 0x20)
-        std::cout << name << std::endl;
+      else {
+        tied_properties.push_back(getNode(name));
+        if (debug_lvl & 0x20) std::cout << name << std::endl;
+      }
     }
 
 
@@ -562,8 +564,10 @@ class FGPropertyManager : public SGPropertyNode, public FGJSBBase
     {
       if (!tie(name.c_str(), SGRawValueFunctionsIndexed<V>(index, getter, setter), useDefault))
         std::cout << "Failed to tie property " << name << " to indexed functions" << std::endl;
-      else if (debug_lvl & 0x20)
-        std::cout << name << std::endl;
+      else {
+        tied_properties.push_back(getNode(name));
+        if (debug_lvl & 0x20) std::cout << name << std::endl;
+      }
     }
 
 
@@ -592,8 +596,10 @@ class FGPropertyManager : public SGPropertyNode, public FGJSBBase
     {
       if (!tie(name.c_str(), SGRawValueMethods<T,V>(*obj, getter, setter), useDefault))
         std::cout << "Failed to tie property " << name << " to object methods" << std::endl;
-      else if (debug_lvl & 0x20)
-        std::cout << name << std::endl;
+      else {
+        tied_properties.push_back(getNode(name));
+        if (debug_lvl & 0x20) std::cout << name << std::endl;
+      }
     }
 
     /**
@@ -621,8 +627,10 @@ class FGPropertyManager : public SGPropertyNode, public FGJSBBase
     {
       if (!tie(name.c_str(), SGRawValueMethodsIndexed<T,V>(*obj, index, getter, setter), useDefault))
         std::cout << "Failed to tie property " << name << " to indexed object methods" << std::endl;
-      else if (debug_lvl & 0x20)
-        std::cout << name << std::endl;
+      else {
+        tied_properties.push_back(getNode(name));
+        if (debug_lvl & 0x20) std::cout << name << std::endl;
+      }
    }
 };
 }
------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to