diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index f166d8b734..b953884ce1 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -624,16 +624,24 @@ int SketchObject::addGeometry(const std::vector &geoList, bool const std::vector< Part::Geometry * > &vals = getInternalGeometry(); std::vector< Part::Geometry * > newVals(vals); + std::vector< Part::Geometry * > copies; + copies.reserve(geoList.size()); for (std::vector::const_iterator it = geoList.begin(); it != geoList.end(); ++it) { - if(construction && (*it)->getTypeId() != Part::GeomPoint::getClassTypeId()) - const_cast(*it)->Construction = construction; - - newVals.push_back(*it); + Part::Geometry* copy = (*it)->copy(); + if(construction && copy->getTypeId() != Part::GeomPoint::getClassTypeId()) { + copy->Construction = construction; + } + + copies.push_back(copy); } + + newVals.insert(newVals.end(), copies.begin(), copies.end()); Geometry.setValues(newVals); + for (std::vector::iterator it = copies.begin(); it != copies.end(); ++it) + delete *it; Constraints.acceptGeometry(getCompleteGeometry()); rebuildVertexIndex(); - + return Geometry.getSize()-1; }