From 7a3e26dc5a4b6f9da02575f58dbca90712b4a178 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sat, 20 Jun 2020 07:26:06 +0200 Subject: [PATCH] PropertyGeometryList: move setValue and refactor --- src/Mod/Part/App/PropertyGeometryList.cpp | 20 ++++++++++++++------ src/Mod/Part/App/PropertyGeometryList.h | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Mod/Part/App/PropertyGeometryList.cpp b/src/Mod/Part/App/PropertyGeometryList.cpp index 71a7978f21..25d0df0b74 100644 --- a/src/Mod/Part/App/PropertyGeometryList.cpp +++ b/src/Mod/Part/App/PropertyGeometryList.cpp @@ -94,15 +94,23 @@ void PropertyGeometryList::setValue(const Geometry* lValue) } void PropertyGeometryList::setValues(const std::vector& lValue) +{ + auto copy = lValue; + for(auto &geo : copy) // copy of the individual geometry pointers + geo = geo->clone(); + + setValues(std::move(copy)); +} + +void PropertyGeometryList::setValues(const std::vector&& rValue) { aboutToSetValue(); std::vector oldVals(_lValueList); - _lValueList.resize(lValue.size()); - // copy all objects - for (unsigned int i = 0; i < lValue.size(); i++) - _lValueList[i] = lValue[i]->clone(); - for (unsigned int i = 0; i < oldVals.size(); i++) - delete oldVals[i]; + _lValueList = std::move(rValue); + + for(auto &ov : oldVals) + delete ov; + hasSetValue(); } diff --git a/src/Mod/Part/App/PropertyGeometryList.h b/src/Mod/Part/App/PropertyGeometryList.h index 4f9fba1c27..2ee789c7fa 100644 --- a/src/Mod/Part/App/PropertyGeometryList.h +++ b/src/Mod/Part/App/PropertyGeometryList.h @@ -64,6 +64,7 @@ public: */ void setValue(const Geometry*); void setValues(const std::vector&); + void setValues(const std::vector&&); /// index operator const Geometry *operator[] (const int idx) const {