for(; aNewIter != theNewRefs.end(); aNewIter++) {
if (aData->refsToMe().find(*aNewIter) == aData->refsToMe().end()) {
FeaturePtr aRefFeat = std::dynamic_pointer_cast<ModelAPI_Feature>((*aNewIter)->owner());
- aData->addBackReference(aRefFeat, (*aNewIter)->id());
+ if (aRefFeat)
+ aData->addBackReference(aRefFeat, (*aNewIter)->id());
+ else // add back reference to a folder
+ aData->addBackReference((*aNewIter)->owner(), (*aNewIter)->id());
}
}
if (theNewRefs.size() != aData->refsToMe().size()) { // some back ref must be removed
{
data()->addAttribute(FIRST_FEATURE_ID(), ModelAPI_AttributeReference::typeId());
data()->addAttribute(LAST_FEATURE_ID(), ModelAPI_AttributeReference::typeId());
- // nullify references for sure
- reference(FIRST_FEATURE_ID())->setValue(ObjectPtr());
- reference(LAST_FEATURE_ID())->setValue(ObjectPtr());
}
void ModelAPI_Folder::execute()
std::set<AttributePtr>::const_iterator anIt;
for (anIt = aRefsList.cbegin(); anIt != aRefsList.cend(); ++anIt) {
FeaturePtr aRefFeature = std::dynamic_pointer_cast<ModelAPI_Feature>((*anIt)->owner());
- if (aRefFeature->getKind() == theFeatureId)
+ if (aRefFeature && aRefFeature->getKind() == theFeatureId)
return aRefFeature;
}
return FeaturePtr();