From: mpv Date: Thu, 18 Aug 2016 11:17:41 +0000 (+0300) Subject: Avoid of reference to not-initialized attributes values X-Git-Tag: V_2.5.0~137^2~27 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=86c9866d34cde9e9678fecd2bdb3bba4e8c2f38b;p=modules%2Fshaper.git Avoid of reference to not-initialized attributes values --- diff --git a/src/GeomValidators/GeomValidators_ZeroOffset.cpp b/src/GeomValidators/GeomValidators_ZeroOffset.cpp index 20d324edd..e66cc4333 100644 --- a/src/GeomValidators/GeomValidators_ZeroOffset.cpp +++ b/src/GeomValidators/GeomValidators_ZeroOffset.cpp @@ -87,11 +87,11 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& double aToSize = 0.0; double aFromSize = 0.0; - if(theFeature->real(*anIt)) { + if(theFeature->real(*anIt) && theFeature->real(*anIt)->isInitialized()) { aToSize = theFeature->real(*anIt)->value(); } anIt++; - if(theFeature->real(*anIt)) { + if(theFeature->real(*anIt) && theFeature->real(*anIt)->isInitialized()) { aFromSize = theFeature->real(*anIt)->value(); } anIt++; @@ -109,7 +109,7 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& std::shared_ptr aFromShape; std::shared_ptr anAttrSel = theFeature->selection(*anIt); - if(anAttrSel) { + if(anAttrSel && anAttrSel->isInitialized()) { aToShape = std::dynamic_pointer_cast(anAttrSel->value()); if(aToShape.get() == NULL && anAttrSel->context().get() != NULL) { aToShape = anAttrSel->context()->shape(); @@ -118,13 +118,13 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& anIt++; std::shared_ptr anAttrDouble = theFeature->real(*anIt); - if(anAttrDouble) { + if(anAttrDouble && anAttrDouble->isInitialized()) { aToSize = anAttrDouble->value(); } anIt++; anAttrSel = theFeature->selection(*anIt); - if(anAttrSel) { + if(anAttrSel && anAttrSel->isInitialized()) { aFromShape = std::dynamic_pointer_cast(anAttrSel->value()); if(aFromShape.get() == NULL && anAttrSel->context().get() != NULL) { aFromShape = anAttrSel->context()->shape(); @@ -133,7 +133,7 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& anIt++; anAttrDouble = theFeature->real(*anIt); - if(anAttrDouble) { + if(anAttrDouble && anAttrDouble->isInitialized()) { aFromSize = anAttrDouble->value(); } diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index a36b0a0c1..6bdd0009b 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -137,11 +137,6 @@ bool PartSet_WidgetPoint2D::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr /// the selection is not possible if the current feature has no presentation for the current /// attribute not in AIS not in results. If so, no object in current feature where make /// coincidence, so selection is not necessary - std::shared_ptr aData = myFeature->data(); - std::shared_ptr aPointAttr = std::dynamic_pointer_cast( - aData->attribute(attributeID())); - std::shared_ptr aPoint = aPointAttr->pnt(); - bool aFoundPoint = false; GeomShapePtr anAISShape; GeomPresentablePtr aPrs = std::dynamic_pointer_cast(myFeature); @@ -157,6 +152,10 @@ bool PartSet_WidgetPoint2D::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr return true; /// analysis of AIS + std::shared_ptr aData = myFeature->data(); + std::shared_ptr aPointAttr = std::dynamic_pointer_cast( + aData->attribute(attributeID())); + std::shared_ptr aPoint = aPointAttr->pnt(); if (anAISShape.get()) aFoundPoint = shapeContainsPoint(anAISShape, aPoint, mySketch);