]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
#1581 crash when create fillet
authornds <nds@opencascade.com>
Thu, 23 Jun 2016 16:18:54 +0000 (19:18 +0300)
committernds <nds@opencascade.com>
Thu, 23 Jun 2016 16:18:54 +0000 (19:18 +0300)
src/ModuleBase/ModuleBase_Tools.cpp
src/ModuleBase/ModuleBase_Tools.h
src/ModuleBase/ModuleBase_WidgetSelector.cpp
src/PartSet/PartSet_WidgetMultiSelector.cpp
src/PartSet/PartSet_WidgetShapeSelector.cpp

index 8045264db33622361bbd0e3ce65240e8ac19b7ad..127ceb3f7d82690f86b6b1b8cc888198f7064c30 100755 (executable)
@@ -785,13 +785,14 @@ bool hasObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
   return aHasObject;
 }
 
-void setObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
+bool setObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
                const GeomShapePtr& theShape, ModuleBase_IWorkshop* theWorkshop,
                const bool theTemporarily, const bool theCheckIfAttributeHasObject)
 {
   if (!theAttribute.get())
-    return;
+    return false;
 
+  bool isDone = true;
   std::string aType = theAttribute->attributeType();
   if (aType == ModelAPI_AttributeReference::typeId()) {
     AttributeReferencePtr aRef = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
@@ -828,8 +829,12 @@ void setObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
   }
   else if (aType == ModelAPI_AttributeRefList::typeId()) {
     AttributeRefListPtr aRefListAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
-    if (!theCheckIfAttributeHasObject || !aRefListAttr->isInList(theObject))
-      aRefListAttr->append(theObject);
+    if (!theCheckIfAttributeHasObject || !aRefListAttr->isInList(theObject)) {
+      if (theObject.get())
+        aRefListAttr->append(theObject);
+      else
+        isDone = false;
+    }
   }
   else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
     AttributeRefAttrListPtr aRefAttrListAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(theAttribute);
@@ -840,10 +845,15 @@ void setObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
         aRefAttrListAttr->append(anAttribute);
     }
     else {
-      if (!theCheckIfAttributeHasObject || !aRefAttrListAttr->isInList(theObject))
-        aRefAttrListAttr->append(theObject);
+      if (!theCheckIfAttributeHasObject || !aRefAttrListAttr->isInList(theObject)) {
+        if (theObject.get())
+          aRefAttrListAttr->append(theObject);
+        else
+          isDone = false;
+      }
     }
   }
+  return isDone;
 }
 
 GeomShapePtr getShape(const AttributePtr& theAttribute, ModuleBase_IWorkshop* theWorkshop)
index e2a10092cd9968c9565b1ef85fc0c8367f6c71bf..665ee6008bb95fd3392ff1871402c044b6428685 100755 (executable)
@@ -223,7 +223,8 @@ MODULEBASE_EXPORT bool hasObject(const AttributePtr& theAttribute, const ObjectP
 /// \param theTemporarily if it is true, do not store and name the added in the data framework
 /// \param theCheckIfAttributeHasObject if it is true, the check isInList is called
 ///        It is useful for attribute selection
-MODULEBASE_EXPORT void setObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
+/// \return true if the attribute is filled with the given parameters
+MODULEBASE_EXPORT bool setObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
                                  const std::shared_ptr<GeomAPI_Shape>& theShape,
                                  ModuleBase_IWorkshop* theWorkshop,
                                  const bool theTemporarily,
index bd0dd48d2c84682a5ba7ef94c1661a65d6c8731c..7e0eb3f0f80fd7985baa43b28af771873f02445a 100755 (executable)
@@ -195,8 +195,7 @@ bool ModuleBase_WidgetSelector::setSelectionCustom(const ModuleBase_ViewerPrsPtr
   getGeomSelection(thePrs, anObject, aShape);
 
   // the last flag is to be depending on hasObject is called before. To be corrected later
-  ModuleBase_Tools::setObject(attribute(), anObject, aShape, myWorkshop, myIsInValidate, true);
-  return true;
+  return ModuleBase_Tools::setObject(attribute(), anObject, aShape, myWorkshop, myIsInValidate, true);
 }
 
 //********************************************************************
index e8695bf2172b8a614ed39739443c2b7d293f6dcb..31006f8927908c96808985396ccafcdff533ab6a 100755 (executable)
@@ -74,7 +74,9 @@ void PartSet_WidgetMultiSelector::getGeomSelection(const ModuleBase_ViewerPrsPtr
           std::dynamic_pointer_cast<SketchPlugin_Feature>(aSelectedFeature);
   // there is no a sketch feature is selected, but the shape exists, try to create an exernal object
   // TODO: unite with the same functionality in PartSet_WidgetShapeSelector
-  if (aSPFeature.get() == NULL && myExternalObjectMgr->useExternal()) {
+  if (aSPFeature.get() == NULL)
+    theObject = NULL;
+  if (myExternalObjectMgr->useExternal()) {
     GeomShapePtr aShape = theShape;
     if (!aShape.get()) {
       ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
index aa20ad82c28af9445c7993988c37e9d1d549e4c4..05a11336796d04af95fdaaadb8568ce8550e2440 100755 (executable)
@@ -78,7 +78,9 @@ void PartSet_WidgetShapeSelector::getGeomSelection(const ModuleBase_ViewerPrsPtr
           std::dynamic_pointer_cast<SketchPlugin_Feature>(aSelectedFeature);
   // there is no a sketch feature is selected, but the shape exists, try to create an exernal object
   // TODO: unite with the same functionality in PartSet_WidgetShapeSelector
-  if (aSPFeature.get() == NULL && myExternalObjectMgr->useExternal()) {
+  if (aSPFeature.get() == NULL)
+    theObject = NULL;
+  if (myExternalObjectMgr->useExternal()) {
     GeomShapePtr aShape = theShape;
     if (!aShape.get()) {
       ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);