From 7778f25584e08daf050b5cf2cf6b7ec7dd79cefd Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 12 Feb 2019 19:40:29 +0100 Subject: [PATCH] copyObject should return the clone of the passed object for recursive copies, not an arbitrary object --- src/App/Document.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 24b793a588..04034ad98b 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -3047,6 +3047,11 @@ DocumentObject* Document::copyObject(DocumentObject* obj, bool recursive) md.setVerbose(recursive); if (recursive) { objs = obj->getDocument()->getDependencyList(objs); + auto it = std::find(objs.begin(), objs.end(), obj); + if (it != objs.end()) { + auto index = std::distance(objs.begin(), it); + std::swap(objs[index], objs.back()); + } } unsigned int memsize=1000; // ~ for the meta-information