From 22527f6fd3fcbdcfbbf314c8ff6232458007013f Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 19 Nov 2009 17:42:25 +0000 Subject: [PATCH] From Stephan Huber, "attached you'll find a bugfix for removeTransformUpdating and another similar remove-method. The old code removed an element from a vector, which invalidates the iterator of the loop This resulted in a crash on certain platforms. Now the erasing is done the right way without invalidating the iterator." --- src/osgManipulator/Dragger.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/osgManipulator/Dragger.cpp b/src/osgManipulator/Dragger.cpp index c18674361..4ba6522a6 100644 --- a/src/osgManipulator/Dragger.cpp +++ b/src/osgManipulator/Dragger.cpp @@ -182,12 +182,15 @@ void Dragger::removeConstraint(Constraint* constraint) { for(Constraints::iterator itr = _constraints.begin(); itr != _constraints.end(); - ++itr) + ) { if (*itr = constraint) { - _constraints.erase(itr); + itr = _constraints.erase(itr); return; + } else + { + ++itr; } } } @@ -201,13 +204,17 @@ void Dragger::removeTransformUpdating(osg::MatrixTransform* transform) { for(Dragger::DraggerCallbacks::iterator itr = _draggerCallbacks.begin(); itr != _draggerCallbacks.end(); - ++itr) + ) { DraggerCallback* dc = itr->get(); DraggerTransformCallback* dtc = dynamic_cast(dc); if (dtc && dtc->getTransform()==transform) { - _draggerCallbacks.erase(itr); + itr = _draggerCallbacks.erase(itr); + } + else + { + ++itr; } }