]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
fix removing from the std::map being iterated over
authoreap <eap@opencascade.com>
Thu, 19 Aug 2010 09:21:03 +0000 (09:21 +0000)
committereap <eap@opencascade.com>
Thu, 19 Aug 2010 09:21:03 +0000 (09:21 +0000)
src/SMESHGUI/SMESHGUI_VTKUtils.cxx

index e210f2c7f659baaed7d8aa73311220382007b81c..72ce1e852964e41b4f20fc343c98c3852a99f16c 100644 (file)
@@ -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++;
       }
     }
   }