]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Set of fixes to avoid crashes on invalid document from issue #2147 opening.
authormpv <mpv@opencascade.com>
Thu, 27 Apr 2017 12:31:28 +0000 (15:31 +0300)
committermpv <mpv@opencascade.com>
Thu, 27 Apr 2017 12:31:28 +0000 (15:31 +0300)
src/BuildPlugin/BuildPlugin_Validators.cpp
src/FeaturesPlugin/FeaturesPlugin_ValidatorTransform.cpp
src/Model/Model_Document.cpp
src/ModelHighAPI/ModelHighAPI_Services.cpp
src/ModelHighAPI/ModelHighAPI_Services.h
src/PythonAPI/model/services/__init__.py
src/PythonAddons/macros/box/feature.py

index fc93bc7dfd204b0f6486da93f2012aaf0f9c2dcb..f82862cbbab792a8d3fb7c889af384628402f923 100644 (file)
@@ -184,6 +184,10 @@ bool BuildPlugin_ValidatorBaseForFace::isValid(const std::shared_ptr<ModelAPI_Fe
     AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
     GeomShapePtr aShape = aSelection->value();
     if(!aShape.get()) {
+      if (!aSelection->context()) {
+        theError = "Objects are not selected.";
+        return false;
+      }
       aShape = aSelection->context()->shape();
     }
     for(GeomAPI_ShapeExplorer anExp(aShape, GeomAPI_Shape::EDGE); anExp.more(); anExp.next()) {
@@ -193,7 +197,7 @@ bool BuildPlugin_ValidatorBaseForFace::isValid(const std::shared_ptr<ModelAPI_Fe
   }
 
   if(anEdges.empty()) {
-    theError = "Objects not selected.";
+    theError = "Objects are not selected.";
     return false;
   }
 
index 23d0c1b6873431a38401fef41d876ae4283516d8..37ba9149fe9e80dbc9cce1ef93da35b6a656f0c3 100755 (executable)
@@ -33,7 +33,10 @@ bool FeaturesPlugin_ValidatorTransform::isValid(const AttributePtr& theAttribute
   for(int i = 0; i < aCurSelList->size() && aValid; i++) {
     std::shared_ptr<ModelAPI_AttributeSelection> aSelAttribute = aCurSelList->value(i);
     ResultPtr aResult = aSelAttribute->context();
-    if (isPartSetDocument) // PartSet document: Result Part is valid
+    if (!aResult) {
+      theError = "Invalid selection.";
+      return false;
+    } if (isPartSetDocument) // PartSet document: Result Part is valid
       aValid = aResult->groupName() == ModelAPI_ResultPart::group();
     else { // Part document: Result CompSolid is valid
       aValid = aResult->groupName() == ModelAPI_ResultBody::group();
index 10d4605f2f9ba6a1c271912defe25b7826e42f41..f73b93a74715085b951bd6a6a01a953429def892 100755 (executable)
@@ -590,6 +590,8 @@ bool Model_Document::finishOperation()
     Events_Loop::loop()->send(aFinishMsg);
   }
 
+  // for open of document with primitive box inside (finish transaction in initAttributes)
+  bool aWasActivatedFlushes = aLoop->activateFlushes(true);
   while(aLoop->hasGrouppedEvent(kCreatedEvent) || aLoop->hasGrouppedEvent(kUpdatedEvent) ||
         aLoop->hasGrouppedEvent(kRedispEvent) || aLoop->hasGrouppedEvent(kDeletedEvent)) {
     aLoop->flush(kCreatedEvent);
@@ -597,6 +599,7 @@ bool Model_Document::finishOperation()
     aLoop->flush(kRedispEvent);
     aLoop->flush(kDeletedEvent);
   }
+  aLoop->activateFlushes(aWasActivatedFlushes);
 
   // to avoid "updated" message appearance by updater
   //aLoop->clear(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
index db14a4601929044d5ca650fa5af690784a91ef5f..5e06355794563968277ff50f4f77e3d1c9088691 100644 (file)
@@ -102,6 +102,13 @@ void apply()
   aSession->startOperation();
 }
 
+void updateFeatures()
+{
+  Events_Loop* aLoop = Events_Loop::loop();
+  aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
+  aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+}
+
 //--------------------------------------------------------------------------------------
 void undo()
 {
index b02e778e9b9c9d9a8fa02fd6107537f3b134392e..03a244cbc4ad97c2dddd35faab6dfde454b12e60 100644 (file)
@@ -75,6 +75,14 @@ void end();
 MODELHIGHAPI_EXPORT
 void apply();
 
+/** Executes features, created or updated before.
+ *
+ *  This method flushes creation and update events in order to make all
+ *  features up to date.
+ */
+MODELHIGHAPI_EXPORT
+void updateFeatures();
+
 /// Roll-back the data structure to the previous control point.
 MODELHIGHAPI_EXPORT
 void undo();
index cf963610652599bb6a658c4c4504fe8f456e2004..8c15e89ecaf19521c50982e8cf42c9c133bbacd0 100644 (file)
@@ -5,6 +5,7 @@ from ModelHighAPI import moduleDocument, activeDocument
 from ModelHighAPI import defaultPlane, standardPlane
 from ModelHighAPI import begin, end
 from ModelHighAPI import apply as do
+from ModelHighAPI import updateFeatures
 from ModelHighAPI import undo, redo
 from ModelHighAPI import reset
 from ModelHighAPI import ModelHighAPI_Selection as selection
index 8c580cdc8b9c3e1d660103382eee6e30ced1aa48..8b9e486e16f2ccc125819d4f03693a0f012e0266 100644 (file)
@@ -82,7 +82,8 @@ class BoxFeature(model.Feature):
         self.base.setPerpendicular(line[0], line[3])
 
         # execute sketch
-        model.do()
+        mypart.setCurrentFeature(self.base.feature(), False)
+        model.updateFeatures()
 
         # Creating the extrusion (the box) at default size
         # A box result