From 8b6f50d0cc88fd49d453373f846c5733bb5d288b Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Wed, 21 Nov 2012 11:57:53 +0100 Subject: [PATCH] SGPropertyNode::fireCreatedRecursive: don't fire for node itself by default --- simgear/canvas/canvas_fwd.hxx | 2 +- simgear/props/props.cxx | 13 ++++++++----- simgear/props/props.hxx | 6 ++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/simgear/canvas/canvas_fwd.hxx b/simgear/canvas/canvas_fwd.hxx index 0eb70b87..a72baf62 100644 --- a/simgear/canvas/canvas_fwd.hxx +++ b/simgear/canvas/canvas_fwd.hxx @@ -63,7 +63,7 @@ namespace canvas typedef osg::ref_ptr FontPtr; typedef std::vector Placements; - typedef boost::function PlacementFactory; } // namespace canvas diff --git a/simgear/props/props.cxx b/simgear/props/props.cxx index 702ad77d..a05547ca 100644 --- a/simgear/props/props.cxx +++ b/simgear/props/props.cxx @@ -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 diff --git a/simgear/props/props.hxx b/simgear/props/props.hxx index f2692710..eaf5fe14 100644 --- a/simgear/props/props.hxx +++ b/simgear/props/props.hxx @@ -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. -- 2.39.5