From: azv Date: Thu, 24 Dec 2015 12:21:11 +0000 (+0300) Subject: Fix some kind of crashes X-Git-Tag: V_2.1.0~68 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cbfb230b4c72dc5925c94b64cb93c690a4c2f069;p=modules%2Fshaper.git Fix some kind of crashes --- diff --git a/src/SketchSolver/SketchSolver_Storage.cpp b/src/SketchSolver/SketchSolver_Storage.cpp index 739de6f95..b8773d92d 100644 --- a/src/SketchSolver/SketchSolver_Storage.cpp +++ b/src/SketchSolver/SketchSolver_Storage.cpp @@ -275,6 +275,8 @@ bool SketchSolver_Storage::removeConstraint(ConstraintPtr theConstraint) template static bool isUsed(ConstraintWrapperPtr theConstraint, ENT_TYPE theEntity) { + if (!theConstraint || !theEntity) + return false; std::list::const_iterator anEntIt = theConstraint->entities().begin(); for (; anEntIt != theConstraint->entities().end(); ++anEntIt) if ((*anEntIt)->isBase(theEntity)) @@ -284,6 +286,8 @@ static bool isUsed(ConstraintWrapperPtr theConstraint, ENT_TYPE theEntity) static bool isUsed(EntityWrapperPtr theFeature, AttributePtr theSubEntity) { + if (!theFeature || !theSubEntity) + return false; std::list::const_iterator aSubIt = theFeature->subEntities().begin(); for (; aSubIt != theFeature->subEntities().end(); ++aSubIt) if ((*aSubIt)->isBase(theSubEntity)) @@ -352,7 +356,7 @@ bool SketchSolver_Storage::removeEntity(FeaturePtr theFeature) myFeatureMap.erase(aFound); // Check if the feature is not used by constraints, remove it - if (!isUsed(theFeature) && remove(anEntity)) + if (!anEntity || (!isUsed(theFeature) && remove(anEntity))) return true; // feature is not removed, revert operation @@ -371,7 +375,7 @@ bool SketchSolver_Storage::removeEntity(AttributePtr theAttribute) myAttributeMap.erase(aFound); // Check if the attribute is not used by constraints and features, remove it - if (!isUsed(theAttribute) && remove(anEntity)) + if (!anEntity || (!isUsed(theAttribute) && remove(anEntity))) return true; // attribute is not removed, revert operation diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp index 3006fd5b8..51699b90f 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp @@ -408,7 +408,12 @@ void SolveSpaceSolver_Storage::replaceInConstraints( aConstr.entityC == aSlvsCIt->entityC && aConstr.entityD == aSlvsCIt->entityD) { Slvs_hConstraint anIDToRemove = aConstr.h; aConstr = *aSlvsCIt; + int aShift = aSlvsCIt - myConstraints.begin(); removeConstraint(anIDToRemove); + aSlvsCIt = myConstraints.begin() + aShift - 1; + for (; aSlvsCIt != myConstraints.end(); ++aSlvsCIt) + if (aSlvsCIt->h == aConstr.h) + break; break; } @@ -1048,6 +1053,8 @@ bool SolveSpaceSolver_Storage::removeCoincidence(ConstraintWrapperPtr theConstra std::set anUpdFeatures; std::map::iterator aFIt = myFeatureMap.begin(); for (; aFIt != myFeatureMap.end(); ++aFIt) { + if (!aFIt->second) + continue; // avoid not completed arcs for (aNotCIt = aNotCoinc.begin(); aNotCIt != aNotCoinc.end(); ++aNotCIt) { if (!aNotCIt->second || !aFIt->second->isUsed(aNotCIt->first->baseAttribute())) continue;