From: azv Date: Wed, 8 Apr 2015 09:38:45 +0000 (+0300) Subject: Avoid crash when removing feature under constraints X-Git-Tag: V_1.1.0~54^2~6^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7e34a29887a288f210715c0a0c776b257052b903;p=modules%2Fshaper.git Avoid crash when removing feature under constraints --- diff --git a/src/SketchSolver/SketchSolver_FeatureStorage.cpp b/src/SketchSolver/SketchSolver_FeatureStorage.cpp index ef8461256..d647d075b 100644 --- a/src/SketchSolver/SketchSolver_FeatureStorage.cpp +++ b/src/SketchSolver/SketchSolver_FeatureStorage.cpp @@ -211,16 +211,32 @@ void SketchSolver_FeatureStorage::removeFeature(FeaturePtr theFeature, Constrain if (aFeatIter == myFeatures.end()) return; // no such feature - std::list anAttributes = theFeature->data()->attributes(std::string()); - std::list::iterator anIter = anAttributes.begin(); - for (; anIter != anAttributes.end(); anIter++) { - AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast(*anIter); - if (aRefAttr) { - if (!aRefAttr->isObject()) - removeAttribute(aRefAttr->attr(), theFeature); - continue; + if (theFeature->data()) { + std::list anAttributes = theFeature->data()->attributes(std::string()); + std::list::iterator anIter = anAttributes.begin(); + for (; anIter != anAttributes.end(); anIter++) { + AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast(*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);