From: mpv Date: Tue, 30 Dec 2014 09:49:18 +0000 (+0300) Subject: Issue #349 : added checking on close of the study crashes X-Git-Tag: V_0.7.0_rc1~10^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=871b614264ee552393170b1dec8942f831fba188;p=modules%2Fshaper.git Issue #349 : added checking on close of the study crashes --- diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 78df67edb..3eb4cc1fb 100644 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -353,23 +353,25 @@ std::shared_ptr PartSet_Tools::sketchPlane(CompositeFeaturePtr theS std::shared_ptr aPlane; std::shared_ptr aData = theSketch->data(); - std::shared_ptr anOrigin = std::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Sketch::ORIGIN_ID())); - std::shared_ptr aNormal = std::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Sketch::NORM_ID())); - if (aNormal && anOrigin) { - double adX = aNormal->x(); - double adY = aNormal->y(); - double adZ = aNormal->z(); - - if ( (adX != 0) || (adY != 0) || (adZ != 0) ) { // Plane is valid - double aX = anOrigin->x(); - double aY = anOrigin->y(); - double aZ = anOrigin->z(); - gp_Pln aPln(gp_Pnt(aX, aY, aZ), gp_Dir(adX, adY, adZ)); - double aA, aB, aC, aD; - aPln.Coefficients(aA, aB, aC, aD); - aPlane = std::shared_ptr(new GeomAPI_Pln(aA, aB, aC, aD)); + if (aData) { + std::shared_ptr anOrigin = std::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::ORIGIN_ID())); + std::shared_ptr aNormal = std::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::NORM_ID())); + if (aNormal && anOrigin) { + double adX = aNormal->x(); + double adY = aNormal->y(); + double adZ = aNormal->z(); + + if ( (adX != 0) || (adY != 0) || (adZ != 0) ) { // Plane is valid + double aX = anOrigin->x(); + double aY = anOrigin->y(); + double aZ = anOrigin->z(); + gp_Pln aPln(gp_Pnt(aX, aY, aZ), gp_Dir(adX, adY, adZ)); + double aA, aB, aC, aD; + aPln.Coefficients(aA, aB, aC, aD); + aPlane = std::shared_ptr(new GeomAPI_Pln(aA, aB, aC, aD)); + } } } return aPlane; diff --git a/src/SketchPlugin/SketchPlugin_Plugin.cpp b/src/SketchPlugin/SketchPlugin_Plugin.cpp index 6680aef33..452e07401 100644 --- a/src/SketchPlugin/SketchPlugin_Plugin.cpp +++ b/src/SketchPlugin/SketchPlugin_Plugin.cpp @@ -129,21 +129,23 @@ std::shared_ptr SketchPlugin_Plugin std::dynamic_pointer_cast(theFeature); if (aSketchFeature.get()) { std::shared_ptr aData = aSketchFeature->data(); - std::shared_ptr aNormal = - std::dynamic_pointer_cast(aData->attribute(SketchPlugin_Sketch::NORM_ID())); - aHasSketchPlane = aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0); - - aMsg->setState(SketchPlugin_Point::ID(), aHasSketchPlane); - aMsg->setState(SketchPlugin_Line::ID(), aHasSketchPlane); - aMsg->setState(SketchPlugin_Circle::ID(), aHasSketchPlane); - aMsg->setState(SketchPlugin_Arc::ID(), aHasSketchPlane); - aMsg->setState(SketchPlugin_ConstraintCoincidence::ID(), aHasSketchPlane); - aMsg->setState(SketchPlugin_ConstraintDistance::ID(), aHasSketchPlane); - aMsg->setState(SketchPlugin_ConstraintLength::ID(), aHasSketchPlane); - aMsg->setState(SketchPlugin_ConstraintParallel::ID(), aHasSketchPlane); - aMsg->setState(SketchPlugin_ConstraintPerpendicular::ID(), aHasSketchPlane); - aMsg->setState(SketchPlugin_ConstraintRadius::ID(), aHasSketchPlane); - aMsg->setState(SketchPlugin_ConstraintRigid::ID(), aHasSketchPlane); + if (aData) { + std::shared_ptr aNormal = + std::dynamic_pointer_cast(aData->attribute(SketchPlugin_Sketch::NORM_ID())); + aHasSketchPlane = aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0); + + aMsg->setState(SketchPlugin_Point::ID(), aHasSketchPlane); + aMsg->setState(SketchPlugin_Line::ID(), aHasSketchPlane); + aMsg->setState(SketchPlugin_Circle::ID(), aHasSketchPlane); + aMsg->setState(SketchPlugin_Arc::ID(), aHasSketchPlane); + aMsg->setState(SketchPlugin_ConstraintCoincidence::ID(), aHasSketchPlane); + aMsg->setState(SketchPlugin_ConstraintDistance::ID(), aHasSketchPlane); + aMsg->setState(SketchPlugin_ConstraintLength::ID(), aHasSketchPlane); + aMsg->setState(SketchPlugin_ConstraintParallel::ID(), aHasSketchPlane); + aMsg->setState(SketchPlugin_ConstraintPerpendicular::ID(), aHasSketchPlane); + aMsg->setState(SketchPlugin_ConstraintRadius::ID(), aHasSketchPlane); + aMsg->setState(SketchPlugin_ConstraintRigid::ID(), aHasSketchPlane); + } } return aMsg; }