PropertyGeometryList: move setValue and refactor

This commit is contained in:
Abdullah Tahiri
2020-06-20 07:26:06 +02:00
committed by abdullahtahiriyo
parent 5119513488
commit 7a3e26dc5a
2 changed files with 15 additions and 6 deletions

View File

@@ -94,15 +94,23 @@ void PropertyGeometryList::setValue(const Geometry* lValue)
}
void PropertyGeometryList::setValues(const std::vector<Geometry*>& 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<Geometry*>&& rValue)
{
aboutToSetValue();
std::vector<Geometry*> 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();
}

View File

@@ -64,6 +64,7 @@ public:
*/
void setValue(const Geometry*);
void setValues(const std::vector<Geometry*>&);
void setValues(const std::vector<Geometry*>&&);
/// index operator
const Geometry *operator[] (const int idx) const {