Salome HOME
Issue #459: Check pre-selection for group operation
[modules/shaper.git] / src / Model / Model_Update.cpp
index f1b4f50ff35fab60a0de7b867d3c56c9b14254ba..142f5c1e12557284b0c4420054f1eb4c42b94dfe 100644 (file)
@@ -112,7 +112,7 @@ void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessag
       for(aFIter = myJustCreatedOrUpdated.begin(); aFIter != myJustCreatedOrUpdated.end(); aFIter++)
       {
         FeaturePtr aF = std::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter);
-        if (aF && aF->getKind() == "Extrusion") {
+        if (aF && aF->data().get() && aF->getKind() == "Extrusion") {
           AttributeSelectionListPtr aBase = aF->selectionList("base");
           if (aBase.get()) {
             for(int a = aBase->size() - 1; a >= 0; a--) {
@@ -221,8 +221,8 @@ bool Model_Update::updateFeature(FeaturePtr theFeature)
     CompositeFeaturePtr aComposite = 
       std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
     if (aComposite) {
-      int aSubsNum = aComposite->numberOfSubs();
-      for(int a = 0; a < aSubsNum; a++) {
+      // number of subs can be changed in execution: like fillet
+      for(int a = 0; a < aComposite->numberOfSubs(); a++) {
         if (updateFeature(aComposite->subFeature(a)))
           aMustbeUpdated = true;
       }
@@ -290,8 +290,8 @@ bool Model_Update::updateFeature(FeaturePtr theFeature)
               // for sketch after update of plane (by update of selection attribute)
               // but before execute, all sub-elements also must be updated (due to the plane changes)
               if (aComposite) {
-                int aSubsNum = aComposite->numberOfSubs();
-                for(int a = 0; a < aSubsNum; a++) {
+                // number of subs can be changed in execution: like fillet
+                for(int a = 0; a < aComposite->numberOfSubs(); a++) {
                   FeaturePtr aSub = aComposite->subFeature(a);
                   bool aWasModified = myUpdated[aSub];
                   myUpdated.erase(myUpdated.find(aSub)); // erase to update for sure (plane may be changed)
@@ -301,7 +301,7 @@ bool Model_Update::updateFeature(FeaturePtr theFeature)
                 }
                 // re-execute after update: solver may update the previous values, so, shapes must be
                 // updated
-                for(int a = 0; a < aSubsNum; a++) {
+                for(int a = 0; a < aComposite->numberOfSubs(); a++) {
                   if (aComposite->subFeature(a) && aFactory->validate(aComposite->subFeature(a)))
                     aComposite->subFeature(a)->execute();
                 }