]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix crash on changing attributes of Mirror constraint
authorazv <azv@opencascade.com>
Fri, 17 Apr 2015 14:00:35 +0000 (17:00 +0300)
committerazv <azv@opencascade.com>
Fri, 17 Apr 2015 14:01:12 +0000 (17:01 +0300)
src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp
src/SketchSolver/SketchSolver_ConstraintMirror.cpp

index d3ba226f6205b57c555ca4f8d7c084c484d100fe..029200ff814e2205be9f937e75a154383067a6e9 100644 (file)
@@ -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<ModelAPI_Data> aData = data();
   AttributeRefListPtr aRefListOfShapes = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
       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)
index 6bb2a9088823a1e1a46cd23f5fa3301dcf5ad140..50d578a668826c4350b8cc690afa629b087117b6 100644 (file)
@@ -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<Slvs_Entity>::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<FeaturePtr, Slvs_hEntity>::iterator aFeatIt = myFeatureMap.begin();
+  for (; aFeatIt != myFeatureMap.end(); aFeatIt++)
+    myStorage->removeEntity(aFeatIt->second);
+
   if (isFullyRemoved) {
     myFeatureMap.clear();
     myAttributeMap.clear();