From 45e906ed668e41007aa64ebbae6f4d62959372fc Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sun, 31 May 2020 09:16:01 +0200 Subject: [PATCH] Sketcher: Fix undo on moving geometry ===================================== fixes #3842 --- src/Mod/Sketcher/App/SketchObject.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 4def5c85f0..8cab499cc8 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -3626,9 +3626,10 @@ int SketchObject::addCopy(const std::vector &geoIdList, const Base::Vector3 } } - for (std::vector::const_iterator it = newgeoIdList.begin(); it != newgeoIdList.end(); ++it) { + int index = 0; + for (std::vector::const_iterator it = newgeoIdList.begin(); it != newgeoIdList.end(); ++it, index++) { const Part::Geometry *geo = getGeometry(*it); - Part::Geometry *geocopy = moveonly?const_cast(geo):geo->copy(); + Part::Geometry *geocopy = geo->copy(); // make a copy of the pointer for undo even if moving // Handle Geometry if(geocopy->getTypeId() == Part::GeomLineSegment::getClassTypeId()){ @@ -3736,6 +3737,9 @@ int SketchObject::addCopy(const std::vector &geoIdList, const Base::Vector3 geoIdMap.insert(std::make_pair(*it, cgeoid)); cgeoid++; } + else { + newgeoVals[index] = geocopy; + } } if(!moveonly) { @@ -3963,9 +3967,8 @@ int SketchObject::addCopy(const std::vector &geoIdList, const Base::Vector3 } } + geoIdMap.clear(); // after each creation reset map so that the key-value is univoque (only for operations other than move) } - - geoIdMap.clear(); // after each creation reset map so that the key-value is univoque } }