[osg-users] Removing and re-adding an update callback

23 views
Skip to first unread message

David Longest

unread,
Mar 28, 2013, 12:06:12 PM3/28/13
to osg-...@lists.openscenegraph.org

Hello,

 

I have encountered a crash bug when re-adding an update callback that has nested callbacks from OSG trunk’s revision 13155. What seems to happen is that the nested callbacks are not cleared when a callback is removed from the middle of the nestedcallback linked list, causing a stack overflow.

 

Example code:

osg::NodeCallback* callback1 = new osg::NodeCallback();

osg::NodeCallback* callback2 = new osg::NodeCallback();

osg::NodeCallback* callback3 = new osg::NodeCallback();

osg::Node* myNode = new osg::Node();

 

// Callback order: 1

myNode->addUpdateCallback(callback1);

 

// Callback order: 1 -> 2

myNode->addUpdateCallback(callback2);

 

// Callback order: 1-> 2 -> 3

myNode->addUpdateCallback(callback3);

 

// Callback order: 1 -> 3

// Removing the second callback will not remove the nested callback from callback2

myNode->removeUpdateCallback(callback2);

 

// Callback order: 1 -> 3 -> 2 -> 3 -> 2 ->3 ->2 ( cyclic nested callbacks)

myNode->addUpdateCallback(callback2);

 

Is there a reason not to clear the removed callback’s nested callbacks? If there are reasons that the removeUpdateCallback should not remove the callback’s nested functions, I think this behavior should be documented.

 

Thanks,

David

Robert Osfield

unread,
Mar 28, 2013, 12:15:55 PM3/28/13
to OpenSceneGraph Users
Hi David,

This looks like a bug to me. I can't have thought deeply enough about
the issue of removing of nested callbacks when I added the support for
nesting callback, ohh quite a few years back now so I can only vaguely
remember doing the work.

Any chance you can spot a bug fix for it? If so send it along to
osg-submissions so I can review and merge it :-) If not I'll get
round to it myself.

Robert.
> _______________________________________________
> osg-users mailing list
> osg-...@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Robert Osfield

unread,
Jun 10, 2013, 6:49:06 AM6/10/13
to OpenSceneGraph Users
Hi All,

A wee update on this thread. I have now checked in a fix that fixes
both the NodeCallback::addNestedCallback() so it appends the nested
callback to the last callback in the chain - previously it would
insert the new nested callback rather than append leading to less than
obvious ordering, and fixed the removeNestedCallback so that it
removed any reference left to the nested callback's nested callback.

Cheers,
Robert.
Reply all
Reply to author
Forward
0 new messages