From: azv Date: Fri, 17 Apr 2015 14:00:35 +0000 (+0300) Subject: Fix crash on changing attributes of Mirror constraint X-Git-Tag: V_1.1.0~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4dec3bf0332d1d6352439dc475cb830bc81de704;p=modules%2Fshaper.git Fix crash on changing attributes of Mirror constraint --- diff --git a/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp b/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp index d3ba226f6..029200ff8 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp @@ -44,6 +44,12 @@ void SketchPlugin_ConstraintMirror::execute() AttributeSelectionListPtr aMirrorObjectRefs = selectionList(SketchPlugin_ConstraintMirror::MIRROR_LIST_ID()); + // Wait all objects being created, then send update events + static Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); + bool isUpdateFlushed = Events_Loop::loop()->isFlushed(anUpdateEvent); + if (isUpdateFlushed) + Events_Loop::loop()->setFlushed(anUpdateEvent, false); + std::shared_ptr aData = data(); AttributeRefListPtr aRefListOfShapes = std::dynamic_pointer_cast( aData->attribute(SketchPlugin_Constraint::ENTITY_B())); @@ -177,6 +183,10 @@ void SketchPlugin_ConstraintMirror::execute() aRefListOfMirrored->append(aNewFeature); } } + + // send events to update the sub-features by the solver + if (isUpdateFlushed) + Events_Loop::loop()->setFlushed(anUpdateEvent, true); } AISObjectPtr SketchPlugin_ConstraintMirror::getAISObject(AISObjectPtr thePrevious) diff --git a/src/SketchSolver/SketchSolver_ConstraintMirror.cpp b/src/SketchSolver/SketchSolver_ConstraintMirror.cpp index 6bb2a9088..50d578a66 100644 --- a/src/SketchSolver/SketchSolver_ConstraintMirror.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintMirror.cpp @@ -57,7 +57,13 @@ void SketchSolver_ConstraintMirror::getAttributes( continue; anEntity = changeEntity(aFeature, aType); - aList->push_back(myStorage->getEntity(anEntity)); + // Sort entities by their type + std::vector::iterator anIt = aList->begin(); + for (; anIt != aList->end(); anIt++) + if (aType < anIt->type) + break; +// aList->push_back(myStorage->getEntity(anEntity)); + aList->insert(anIt, myStorage->getEntity(anEntity)); } } @@ -226,6 +232,10 @@ bool SketchSolver_ConstraintMirror::remove(ConstraintPtr theConstraint) isFullyRemoved = myStorage->removeConstraint(*aCIter) && isFullyRemoved; mySlvsConstraints.clear(); + std::map::iterator aFeatIt = myFeatureMap.begin(); + for (; aFeatIt != myFeatureMap.end(); aFeatIt++) + myStorage->removeEntity(aFeatIt->second); + if (isFullyRemoved) { myFeatureMap.clear(); myAttributeMap.clear();