From: eap Date: Thu, 19 Aug 2010 09:21:03 +0000 (+0000) Subject: fix removing from the std::map being iterated over X-Git-Tag: end_translate_resources_09Jul10~13 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=commitdiff_plain;h=14c9e5320c67f37c9237530cf23ca588d284f1a2;ds=sidebyside fix removing from the std::map being iterated over --- diff --git a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx index e210f2c7f..72ce1e852 100644 --- a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx @@ -204,13 +204,16 @@ namespace SMESH } } TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.begin(); - for ( ; anIter != VISUAL_OBJ_CONT.end(); ++anIter ) { + for ( ; anIter != VISUAL_OBJ_CONT.end(); ) { int curId = anIter->first.first; if ( curId == studyID ) { // for unknown reason, object destructor is not called, so clear object manually anIter->second->GetUnstructuredGrid()->SetCells(0,0,0); anIter->second->GetUnstructuredGrid()->SetPoints(0); - VISUAL_OBJ_CONT.erase( anIter-- ); // dercement occures before erase() + VISUAL_OBJ_CONT.erase( anIter++ ); // anIter++ returns a copy of self before incrementing + } + else { + anIter++; } } }