]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 8 Apr 2015 09:39:39 +0000 (12:39 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 8 Apr 2015 09:39:39 +0000 (12:39 +0300)
src/SketchSolver/SketchSolver_FeatureStorage.cpp

index ef84612566b6d5249e188ba03c392ec2c8c76bc0..d647d075b6f1cca79b74cf3d17e4dd20bd5e21b2 100644 (file)
@@ -211,16 +211,32 @@ void SketchSolver_FeatureStorage::removeFeature(FeaturePtr theFeature, Constrain
   if (aFeatIter == myFeatures.end())
     return; // no such feature
 
-  std::list<AttributePtr> anAttributes = theFeature->data()->attributes(std::string());
-  std::list<AttributePtr>::iterator anIter = anAttributes.begin();
-  for (; anIter != anAttributes.end(); anIter++) {
-    AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anIter);
-    if (aRefAttr) {
-      if (!aRefAttr->isObject())
-        removeAttribute(aRefAttr->attr(), theFeature);
-      continue;
+  if (theFeature->data()) {
+    std::list<AttributePtr> anAttributes = theFeature->data()->attributes(std::string());
+    std::list<AttributePtr>::iterator anIter = anAttributes.begin();
+    for (; anIter != anAttributes.end(); anIter++) {
+      AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anIter);
+      if (aRefAttr) {
+        if (!aRefAttr->isObject())
+          removeAttribute(aRefAttr->attr(), theFeature);
+        continue;
+      }
+      removeAttribute(*anIter, theFeature);
+    }
+  } else {
+    // iterate on attributes to find items refered to theFeature
+    MapAttributeFeature::iterator anIter = myAttributes.begin();
+    while (anIter != myAttributes.end()) {
+      if (anIter->second.find(theFeature) != anIter->second.end()) {
+        anIter->second.erase(theFeature);
+        if (anIter->second.empty()) {
+          MapAttributeFeature::iterator aDeadIter = anIter++;
+          myAttributes.erase(aDeadIter);
+          continue;
+        }
+      }
+      anIter++;
     }
-    removeAttribute(*anIter, theFeature);
   }
 
   aFeatIter->second.erase(theConstraint);