From: nds Date: Thu, 23 Jun 2016 16:18:54 +0000 (+0300) Subject: #1581 crash when create fillet X-Git-Tag: V_2.4.0~28 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9f55e1929c1786f07659130872cbcf952ce7c099;p=modules%2Fshaper.git #1581 crash when create fillet --- diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 8045264db..127ceb3f7 100755 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -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(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(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(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) diff --git a/src/ModuleBase/ModuleBase_Tools.h b/src/ModuleBase/ModuleBase_Tools.h index e2a10092c..665ee6008 100755 --- a/src/ModuleBase/ModuleBase_Tools.h +++ b/src/ModuleBase/ModuleBase_Tools.h @@ -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& theShape, ModuleBase_IWorkshop* theWorkshop, const bool theTemporarily, diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.cpp b/src/ModuleBase/ModuleBase_WidgetSelector.cpp index bd0dd48d2..7e0eb3f0f 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelector.cpp @@ -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); } //******************************************************************** diff --git a/src/PartSet/PartSet_WidgetMultiSelector.cpp b/src/PartSet/PartSet_WidgetMultiSelector.cpp index e8695bf21..31006f892 100755 --- a/src/PartSet/PartSet_WidgetMultiSelector.cpp +++ b/src/PartSet/PartSet_WidgetMultiSelector.cpp @@ -74,7 +74,9 @@ void PartSet_WidgetMultiSelector::getGeomSelection(const ModuleBase_ViewerPrsPtr std::dynamic_pointer_cast(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); diff --git a/src/PartSet/PartSet_WidgetShapeSelector.cpp b/src/PartSet/PartSet_WidgetShapeSelector.cpp index aa20ad82c..05a113367 100755 --- a/src/PartSet/PartSet_WidgetShapeSelector.cpp +++ b/src/PartSet/PartSet_WidgetShapeSelector.cpp @@ -78,7 +78,9 @@ void PartSet_WidgetShapeSelector::getGeomSelection(const ModuleBase_ViewerPrsPtr std::dynamic_pointer_cast(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);