SGPropertyNode::fireCreatedRecursive: don't fire for node itself by default

This commit is contained in:
Thomas Geymayer
2012-11-21 11:57:53 +01:00
parent 80dc28bfb5
commit 8b6f50d0cc
3 changed files with 13 additions and 8 deletions

View 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

View 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

View 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.