]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for issue #2718: Fatal error when open study with box rotated, translated and...
authormpv <mpv@opencascade.com>
Wed, 24 Oct 2018 13:59:16 +0000 (16:59 +0300)
committermpv <mpv@opencascade.com>
Wed, 24 Oct 2018 13:59:37 +0000 (16:59 +0300)
src/Model/Model_AttributeSelection.cpp
src/Model/Model_Objects.cpp
src/Model/Model_ResultPart.cpp

index 0e95d42a5102c3284eddee86513a813c5a0e49ac..6b008ce7ca9424675180a227a22cf8492801515c 100644 (file)
@@ -954,17 +954,17 @@ void Model_AttributeSelection::selectSubShape(
   CenterType aCenterType = theType[0] == 'v' || theType[0] == 'V' ? // only for vertex-type
     centerTypeByName(aSubShapeName) : NOT_CENTER;
   std::string aType = aCenterType == NOT_CENTER ? theType : "EDGE"; // search for edge now
-  TopAbs_ShapeEnum aShapeType =  TopAbs_ShapeEnum(GeomAPI_Shape::shapeTypeByStr(theType));
   static const GeomShapePtr anEmptyShape;
 
   // first iteration is selection by name without center prefix, second - in case of problem,
   // try with initial name
   for(int aUseCenter = 1; aUseCenter >= 0; aUseCenter--)  {
-    std::string aSubShapeName = theSubShapeName;
     if (aUseCenter == 0 && aCenterType != NOT_CENTER) {
+      aSubShapeName = theSubShapeName;
       aCenterType = NOT_CENTER;
       aType = theType;
     } else if (aUseCenter != 1) continue;
+    TopAbs_ShapeEnum aShapeType =  TopAbs_ShapeEnum(GeomAPI_Shape::shapeTypeByStr(aType));
 
     std::shared_ptr<Model_Document> aDoc =
       std::dynamic_pointer_cast<Model_Document>(owner()->document());
@@ -1036,7 +1036,6 @@ void Model_AttributeSelection::selectSubShape(
         }
       }
     }
-    aSubShapeName = theSubShapeName;
   }
   // invalid
   TDF_Label aSelLab = selectionLabel();
@@ -1473,7 +1472,8 @@ void Model_AttributeSelection::updateInHistory()
             // to avoid detection of part changes by local selection only
             AttributeSelectionPtr aSel =
               std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(*aRef);
-            if (aSel.get() && !aSel->value()->isSame(aSel->context()->shape()))
+            if (aSel.get() && aSel->value().get() &&
+                !aSel->value()->isSame(aSel->context()->shape()))
               continue;
 
             FeaturePtr aRefFeat = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRef)->owner());
index e6116ebbe764594b5f317d0eb4a5438c523b144b..100ec495fe17690c3aabbd1a8277053680e4861a 100644 (file)
@@ -1872,11 +1872,14 @@ void Model_Objects::updateResults(FeaturePtr theFeature, std::set<FeaturePtr>& t
         if (aGroup->Get() == ModelAPI_ResultBody::group().c_str()) {
           aNewBody = createBody(theFeature->data(), aResIndex);
         } else if (aGroup->Get() == ModelAPI_ResultPart::group().c_str()) {
-          std::shared_ptr<ModelAPI_ResultPart> aNewP = createPart(theFeature->data(), aResIndex);
-          theFeature->setResult(aNewP, aResIndex);
-          if (!aNewP->partDoc().get())
-            // create the part result: it is better to restore the previous result if it is possible
-            theFeature->execute();
+          if (aResIndex <= theFeature->results().size()) { // to avoid crash if previous execute
+            // for index = 0 erases result
+            std::shared_ptr<ModelAPI_ResultPart> aNewP = createPart(theFeature->data(), aResIndex);
+            theFeature->setResult(aNewP, aResIndex);
+            if (!aNewP->partDoc().get())
+              // create the part result: it is better to restore the previous result if it is possible
+              theFeature->execute();
+          }
         } else if (aGroup->Get() == ModelAPI_ResultConstruction::group().c_str()) {
           ResultConstructionPtr aConstr = createConstruction(theFeature->data(), aResIndex);
           if (!aConstr->updateShape())
index 255f5e3802ce81352513e45182dd92b5dad70178..c4f6f309e207b762e1d00d5c4b41ad94b417ebf0 100644 (file)
@@ -169,6 +169,8 @@ std::shared_ptr<GeomAPI_Shape> Model_ResultPart::shape()
 {
   std::shared_ptr<GeomAPI_Shape> aResult(new GeomAPI_Shape);
   if (myShape.IsNull()) { // shape is not produced yet, create it
+    SessionPtr aMgr = ModelAPI_Session::get();
+    bool aToSendUpdate = aMgr->isOperation(); // inside of operation may send an update evnet
     if (myTrsf.get()) { // get shape of the base result and apply the transformation
       ResultPtr anOrigResult = baseRef();
       std::shared_ptr<GeomAPI_Shape> anOrigShape = anOrigResult->shape();
@@ -180,6 +182,10 @@ std::shared_ptr<GeomAPI_Shape> Model_ResultPart::shape()
           aResult->setImpl(new TopoDS_Shape(aShape));
         }
       }
+      if (!myShape.IsNull() && aToSendUpdate) {
+        static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
+        ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent);
+      }
       return aResult;
     } else {
       DocumentPtr aDoc = Model_ResultPart::partDoc();
@@ -205,9 +211,14 @@ std::shared_ptr<GeomAPI_Shape> Model_ResultPart::shape()
         }
       }
     }
+    if (!myShape.IsNull() && aToSendUpdate) {
+      static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
+      ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent);
+    }
   }
-  if (!myShape.IsNull())
+  if (!myShape.IsNull()) {
     aResult->setImpl(new TopoDS_Shape(myShape));
+  }
   return aResult;
 }