Hi David,
On 28 March 2013 17:58, David Longest <[email protected]> wrote:
> I had mentioned a bug found in NodeCallback in the osg-users mailing list.
> This bug was found when re-adding a removed callback. This would cause
> cyclic inclusion of nested callbacks, leading to a stack overflow.
>
> The removeNesterdCallback function will now set the removed NodeCallback’s
> nested callback pointer to NULL when called.
I investigated the issue and implemented two changes - to make sure
addNestedCallback doesn't directly add to the first nested callback,
but only adds it to last the nested callback in the chain, and also I
implemented a similiar change to removeNestedCallback to what you did.
The methods now look like:
inline void addNestedCallback(NodeCallback* nc)
{
if (nc)
{
if (_nestedCallback.valid())
{
_nestedCallback->addNestedCallback(nc);
}
else
{
_nestedCallback = nc;
}
}
}
inline void removeNestedCallback(NodeCallback* nc)
{
if (nc)
{
if (_nestedCallback==nc)
{
ref_ptr<NodeCallback> new_nested_callback =
_nestedCallback->getNestedCallback();
_nestedCallback->setNestedCallback(0);
_nestedCallback = new_nested_callback;
}
else if (_nestedCallback.valid())
{
_nestedCallback->removeNestedCallback(nc);
}
}
}
With this change your test case of adding callback1, callback2,
callback3, results in a order of 1,2,3, then removing callback2 then
adding it back, results in the ordering 1,3,2 as should be expected.
Could you test out svn/trunk to make sure things are working as you expected.
Robert.
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org