From 9146ba7d44ac39237a7ce5ebb9bd4f595dbe4cdd Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 18 Oct 2013 08:37:18 +0000 Subject: [PATCH] From Vladimir Chebeav, fix for removal of nested callbacks --- include/osg/Node | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/include/osg/Node b/include/osg/Node index 343277468..b5eb8d930 100644 --- a/include/osg/Node +++ b/include/osg/Node @@ -201,7 +201,11 @@ class OSG_EXPORT Node : public Object /** Convenience method that removes a given callback from a node, even if that callback is nested. There is no error return in case the given callback is not found. */ inline void removeUpdateCallback(NodeCallback* nc) { if (nc != NULL && _updateCallback.valid()) { - if (_updateCallback == nc) setUpdateCallback(nc->getNestedCallback()); // replace the callback by the nested one + if (_updateCallback == nc) + { + setUpdateCallback(nc->getNestedCallback()); // replace the callback by the nested one + nc->setNestedCallback(0); + } else _updateCallback->removeNestedCallback(nc); } } @@ -231,7 +235,11 @@ class OSG_EXPORT Node : public Object /** Convenience method that removes a given callback from a node, even if that callback is nested. There is no error return in case the given callback is not found. */ inline void removeEventCallback(NodeCallback* nc) { if (nc != NULL && _eventCallback.valid()) { - if (_eventCallback == nc) setEventCallback(nc->getNestedCallback()); // replace the callback by the nested one + if (_eventCallback == nc) + { + setEventCallback(nc->getNestedCallback()); // replace the callback by the nested one + nc->setNestedCallback(0); + } else _eventCallback->removeNestedCallback(nc); } } @@ -261,7 +269,11 @@ class OSG_EXPORT Node : public Object /** Convenience method that removes a given callback from a node, even if that callback is nested. There is no error return in case the given callback is not found. */ inline void removeCullCallback(NodeCallback* nc) { if (nc != NULL && _cullCallback.valid()) { - if (_cullCallback == nc) setCullCallback(nc->getNestedCallback()); // replace the callback by the nested one + if (_cullCallback == nc) + { + setCullCallback(nc->getNestedCallback()); // replace the callback by the nested one + nc->setNestedCallback(0); + } else _cullCallback->removeNestedCallback(nc); } }