fix bug and possible crash in overloaded method PropertyLinkSubList::setValues

This commit is contained in:
wmayer
2018-03-30 11:37:42 +02:00
parent 33a4055390
commit ef864f2c15

View File

@@ -703,10 +703,10 @@ void PropertyLinkSubList::setValue(DocumentObject* lValue,const char* SubName)
}
void PropertyLinkSubList::setValues(const std::vector<DocumentObject*>& lValue,const std::vector<const char*>& lSubNames)
{
{
if (lValue.size() != lSubNames.size())
throw Base::ValueError("PropertyLinkSubList::setValues: size of subelements list != size of objects list");
#ifndef USE_OLD_DAG
//maintain backlinks.
if (getContainer() && getContainer()->isDerivedFrom(App::DocumentObject::getClassTypeId())) {
@@ -731,8 +731,10 @@ void PropertyLinkSubList::setValues(const std::vector<DocumentObject*>& lValue,c
_lValueList = lValue;
_lSubList.resize(lSubNames.size());
int i = 0;
for (std::vector<const char*>::const_iterator it = lSubNames.begin();it!=lSubNames.end();++it)
_lSubList[i] = *it;
for (std::vector<const char*>::const_iterator it = lSubNames.begin();it!=lSubNames.end();++it,++i) {
if (*it != nullptr)
_lSubList[i] = *it;
}
hasSetValue();
}