From ae2942e747c1be95eae668b87063f9416f85f122 Mon Sep 17 00:00:00 2001 From: azv Date: Mon, 26 May 2014 14:57:55 +0400 Subject: [PATCH] The crash was fixed in SketchSolver on undo/redo operations --- .../SketchSolver_ConstraintManager.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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; -- 2.39.2