- if (theCheck) {
- // check the feature: it must have no depended objects on it
- std::list<ResultPtr>::const_iterator aResIter = theFeature->results().cbegin();
- for(; aResIter != theFeature->results().cend(); aResIter++) {
- std::shared_ptr<Model_Data> aData =
- std::dynamic_pointer_cast<Model_Data>((*aResIter)->data());
- if (aData && !aData->refsToMe().empty()) {
- Events_Error::send(
- "Feature '" + theFeature->data()->name() + "' is used and can not be deleted");
- return;
+ // check the feature: it must have no depended objects on it
+ // the dependencies can be in the feature results
+ std::list<ResultPtr>::const_iterator aResIter = theFeature->results().cbegin();
+ for(; aResIter != theFeature->results().cend(); aResIter++) {
+ ResultPtr aResult = (*aResIter);
+ std::shared_ptr<Model_Data> aData =
+ std::dynamic_pointer_cast<Model_Data>(aResult->data());
+ if (aData.get() != NULL) {
+ const std::set<AttributePtr>& aRefs = aData->refsToMe();
+ std::set<AttributePtr>::const_iterator aRefIt = aRefs.begin(), aRefLast = aRefs.end();
+ for(; aRefIt != aRefLast; aRefIt++) {
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRefIt)->owner());
+ if (aFeature.get() != NULL)
+ theRefs.insert(aFeature);
+ }
+
+ if (!aRefs.empty()) {
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aResult);
+ if (aFeature.get() != NULL)
+ theRefs.insert(aFeature);