Salome HOME
Issue #20469: crash when creating wire
[modules/shaper.git] / src / BuildPlugin / BuildPlugin_Wire.cpp
index 57d001894519c213605cfe433320947e2f12d434..e56d0b2d1cb58339e01c5afabf70d3814d9c99e2 100644 (file)
@@ -396,7 +396,9 @@ bool buildSketchWires(FeaturePtr theSketchFeature, GeomShapePtr theSketchShape,
       else {
         // both vertices are found
         aFoundStart->second->push_back(anEdge);
-        if (aFoundStart->second != aFoundEnd->second) {
+        if (aFoundStart->second == aFoundEnd->second)
+          aMapVW.erase(aFoundStart);
+        else {
           // different wires => merge segments
           aFoundStart->second->insert(aFoundStart->second->end(),
               aFoundEnd->second->begin(), aFoundEnd->second->end());
@@ -407,9 +409,8 @@ bool buildSketchWires(FeaturePtr theSketchFeature, GeomShapePtr theSketchShape,
               break;
             }
           aNewWires.erase(aFoundEnd->second);
+          aMapVW.erase(aFoundEnd);
         }
-        aMapVW.erase(aFoundStart);
-        aMapVW.erase(aFoundEnd);
         continue;
       }
     }