Salome HOME
Updated copyright comment
[modules/shaper.git] / src / PartSet / PartSet_OverconstraintListener.cpp
index 5db78193f6a92f367f127386aa3415f9668404ea..b8924b8a27bc59237d8b7a931efaa3dfede4de3a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2021  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2024  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -238,12 +238,11 @@ void PartSet_OverconstraintListener::processEvent(const std::shared_ptr<Events_M
     if (aConstraintsMsg.get()) {
       myObjectsToRemove = aConstraintsMsg->constraints();
 
-      std::set<ObjectPtr>::const_iterator
-        anIt = myObjectsToRemove.begin(), aLast = myObjectsToRemove.end();
+      std::set<ObjectPtr>::const_iterator anIt = myObjectsToRemove.begin();
 
       PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
 
-      for (; anIt != aLast; anIt++)
+      for (; anIt != myObjectsToRemove.end(); )
       {
         ObjectPtr anObject = *anIt;
         FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObject);
@@ -251,7 +250,9 @@ void PartSet_OverconstraintListener::processEvent(const std::shared_ptr<Events_M
         if ((aType == SketchPlugin_ConstraintHorizontal::ID() ||
              aType == SketchPlugin_ConstraintVertical::ID()) &&
              !aModule->sketchReentranceMgr()->isLastAutoConstraint(*anIt))
-          myObjectsToRemove.erase(*anIt);
+          anIt = myObjectsToRemove.erase(anIt);
+        else
+          anIt++;
       }
 
       if (myObjectsToRemove.empty())