]> git.mxchange.org Git - simgear.git/commitdiff
SGPropertyNode::fireCreatedRecursive: don't fire for node itself by default
authorThomas Geymayer <tomgey@gmail.com>
Wed, 21 Nov 2012 10:57:53 +0000 (11:57 +0100)
committerThomas Geymayer <tomgey@gmail.com>
Wed, 21 Nov 2012 10:58:07 +0000 (11:58 +0100)
simgear/canvas/canvas_fwd.hxx
simgear/props/props.cxx
simgear/props/props.hxx

index 0eb70b87dea1b10554ea2970e1ab2c9e9a1d00b3..a72baf62e4bbec4b3c29916b019514b2b1b21e86 100644 (file)
@@ -63,7 +63,7 @@ namespace canvas
   typedef osg::ref_ptr<osgText::Font> FontPtr;
 
   typedef std::vector<PlacementPtr> Placements;
-  typedef boost::function<Placements( const SGPropertyNode*,
+  typedef boost::function<Placements( SGPropertyNode*,
                                       CanvasPtr )> PlacementFactory;
 
 } // namespace canvas
index 702ad77dfc02b5b823186fd9f1801bf7b0d7db89..a05547cab45469515e48df8911fa2b3c1c210b21 100644 (file)
@@ -2139,15 +2139,18 @@ SGPropertyNode::fireChildAdded (SGPropertyNode * child)
 }
 
 void
-SGPropertyNode::fireCreatedRecursive()
+SGPropertyNode::fireCreatedRecursive(bool fire_self)
 {
-  _parent->fireChildAdded(this);
+  if( fire_self )
+  {
+    _parent->fireChildAdded(this);
 
-  if( _children.empty() && getType() != simgear::props::NONE )
-    return fireValueChanged();
+    if( _children.empty() && getType() != simgear::props::NONE )
+      return fireValueChanged();
+  }
 
   for(size_t i = 0; i < _children.size(); ++i)
-    _children[i]->fireCreatedRecursive();
+    _children[i]->fireCreatedRecursive(true);
 }
 
 void
index f2692710de76cf13d9043d68c8132d8a9944b9d1..eaf5fe1479f7937c517a0dd7c04ae10769b2c9f3 100644 (file)
@@ -1597,12 +1597,14 @@ public:
 
   /**
    * Trigger a child-added and value-changed event for every child (Unlimited
-   * depth) and the node itself.
+   * depth).
+   *
+   * @param fire_self   Whether to trigger the events also for the node itself.
    *
    * It can be used to simulating the creation of a property tree, eg. for
    * (re)initializing a subsystem which is controlled through the property tree.
    */
-  void fireCreatedRecursive();
+  void fireCreatedRecursive(bool fire_self = false);
 
   /**
    * Fire a child-removed event to all listeners.