From: azv Date: Thu, 2 Jun 2016 11:57:43 +0000 (+0300) Subject: Fix crashes caused by PlaneGCSSolver connector (issue #1538) X-Git-Tag: V_2.3.1~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ade6b55317ffd71cfc66cde8294bad4b06c4dc84;p=modules%2Fshaper.git Fix crashes caused by PlaneGCSSolver connector (issue #1538) --- diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_ParameterWrapper.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_ParameterWrapper.cpp index 0a271ffab..9c0dfde11 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_ParameterWrapper.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_ParameterWrapper.cpp @@ -16,7 +16,8 @@ PlaneGCSSolver_ParameterWrapper::PlaneGCSSolver_ParameterWrapper(double *const t PlaneGCSSolver_ParameterWrapper::~PlaneGCSSolver_ParameterWrapper() { - delete myValue; + if (!myProcessing) + delete myValue; } void PlaneGCSSolver_ParameterWrapper::setValue(double theValue) diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp index efd48c361..b7c7591af 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp @@ -15,9 +15,7 @@ PlaneGCSSolver_Solver::~PlaneGCSSolver_Solver() void PlaneGCSSolver_Solver::clear() { - std::set::const_iterator anIt = myConstraints.begin(); - for (; anIt != myConstraints.end(); ++anIt) - myEquationSystem.removeConstraint(*anIt); + myEquationSystem.clear(); myConstraints.clear(); myParameters.clear(); } @@ -80,8 +78,10 @@ SketchSolver_SolveStatus PlaneGCSSolver_Solver::solve() if (aResult == GCS::Success) { myEquationSystem.applySolution(); aStatus = STATUS_OK; - } else + } else { + undo(); aStatus = STATUS_FAILED; + } return aStatus; } diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp index 0c00e3064..84dc0c972 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp @@ -239,6 +239,16 @@ bool PlaneGCSSolver_Storage::remove(ConstraintWrapperPtr theConstraint) bool PlaneGCSSolver_Storage::remove(EntityWrapperPtr theEntity) { bool isFullyRemoved = SketchSolver_Storage::remove(theEntity); + if (theEntity->type() == ENTITY_ARC) { + // remove arc additional constraints + std::map >::iterator + aFound = myArcConstraintMap.find(theEntity); + if (aFound != myArcConstraintMap.end()) { + myRemovedConstraints.insert(myRemovedConstraints.end(), + aFound->second.begin(), aFound->second.end()); + myArcConstraintMap.erase(aFound); + } + } if (isFullyRemoved && theEntity->id() == myEntityLastID) --myEntityLastID; return isFullyRemoved; @@ -257,6 +267,7 @@ bool PlaneGCSSolver_Storage::remove(ParameterWrapperPtr theParameter) if (anIt != myParameters.end()) { myParameters.erase(anIt); setNeedToResolve(true); + aParam->setProcessed(false); } else { for (anIt = myConst.begin(); anIt != myConst.end(); ++anIt) @@ -265,10 +276,10 @@ bool PlaneGCSSolver_Storage::remove(ParameterWrapperPtr theParameter) if (anIt != myConst.end()) { myConst.erase(anIt); setNeedToResolve(true); + aParam->setProcessed(false); } } } - aParam->setProcessed(false); return true; } @@ -531,6 +542,7 @@ void PlaneGCSSolver_Storage::initializeSolver(SolverPtr theSolver) std::dynamic_pointer_cast(theSolver); if (!aSolver) return; + aSolver->clear(); if (myExistArc) processArcs(); diff --git a/src/SketchSolver/SketchSolver_Storage.cpp b/src/SketchSolver/SketchSolver_Storage.cpp index 688f6b35a..a3b68b087 100644 --- a/src/SketchSolver/SketchSolver_Storage.cpp +++ b/src/SketchSolver/SketchSolver_Storage.cpp @@ -602,8 +602,13 @@ bool SketchSolver_Storage::remove(EntityWrapperPtr theEntity) FeaturePtr aBaseFeature = (*anEntIt)->baseFeature(); if (aBaseFeature) isFullyRemoved = SketchSolver_Storage::removeEntity(aBaseFeature) && isFullyRemoved; - else - isFullyRemoved = SketchSolver_Storage::removeEntity((*anEntIt)->baseAttribute()) && isFullyRemoved; + else { + AttributePtr aBaseAttr = (*anEntIt)->baseAttribute(); + if (aBaseAttr) + isFullyRemoved = SketchSolver_Storage::removeEntity(aBaseAttr) && isFullyRemoved; + else + remove(*anEntIt); + } } std::list::const_iterator aParIt = theEntity->parameters().begin();