From: azv Date: Mon, 26 May 2014 10:57:55 +0000 (+0400) Subject: The crash was fixed in SketchSolver on undo/redo operations X-Git-Tag: V_0.2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ae2942e747c1be95eae668b87063f9416f85f122;p=modules%2Fshaper.git The crash was fixed in SketchSolver on undo/redo operations --- diff --git a/src/SketchSolver/SketchSolver_ConstraintManager.cpp b/src/SketchSolver/SketchSolver_ConstraintManager.cpp index 80a1b4872..230baf794 100644 --- a/src/SketchSolver/SketchSolver_ConstraintManager.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintManager.cpp @@ -704,6 +704,10 @@ void SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::resolveConstr void SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::mergeGroups( const SketchSolver_ConstraintGroup& theGroup) { + // If specified group is empty, no need to merge + if (theGroup.myConstraintMap.size() == 0) + return ; + // NOTE: The possibility, that some elements are placed into both groups, is around 0, // so the objects should be copied with changing the indexes @@ -767,7 +771,11 @@ void SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::mergeGroups( std::map, Slvs_hConstraint>::const_iterator aSPConstrMapIter = theGroup.myConstraintMap.begin(); for ( ; aSPConstrMapIter!= theGroup.myConstraintMap.end(); aSPConstrMapIter++) - myConstraintMap[aSPConstrMapIter->first] = aConstrMap.find(aSPConstrMapIter->second)->second; + { + std::map::iterator aFind = aConstrMap.find(aSPConstrMapIter->second); + if (aFind != aConstrMap.end()) + myConstraintMap[aSPConstrMapIter->first] = aFind->second; + } std::map, Slvs_hEntity>::const_iterator aSPEntMapIter = theGroup.myEntityMap.begin(); @@ -780,7 +788,11 @@ void SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::mergeGroups( // Add temporary constraints std::list::const_iterator aTempConstrIter = theGroup.myTempConstraints.begin(); for ( ; aTempConstrIter != theGroup.myTempConstraints.end(); aTempConstrIter++) - myTempConstraints.push_back(aConstrMap.find(*aTempConstrIter)->second); + { + std::map::iterator aFind = aConstrMap.find(*aTempConstrIter); + if (aFind != aConstrMap.end()) + myTempConstraints.push_back(aFind->second); + } myTempConstraints.sort(); myNeedToSolve = myNeedToSolve || theGroup.myNeedToSolve;