]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #349 : added checking on close of the study crashes
authormpv <mpv@opencascade.com>
Tue, 30 Dec 2014 09:49:18 +0000 (12:49 +0300)
committermpv <mpv@opencascade.com>
Tue, 30 Dec 2014 09:49:18 +0000 (12:49 +0300)
src/PartSet/PartSet_Tools.cpp
src/SketchPlugin/SketchPlugin_Plugin.cpp

index 78df67edb61f3a0f9a98e7400a2e967329eb67e8..3eb4cc1fb6f2b4f24a879494ad909d804ec2ead5 100644 (file)
@@ -353,23 +353,25 @@ std::shared_ptr<GeomAPI_Pln> PartSet_Tools::sketchPlane(CompositeFeaturePtr theS
   std::shared_ptr<GeomAPI_Pln> aPlane;
 
   std::shared_ptr<ModelAPI_Data> aData = theSketch->data();
-  std::shared_ptr<GeomDataAPI_Point> anOrigin = std::dynamic_pointer_cast<GeomDataAPI_Point>(
-      aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
-  std::shared_ptr<GeomDataAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-      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<GeomAPI_Pln>(new GeomAPI_Pln(aA, aB, aC, aD));
+  if (aData) {
+    std::shared_ptr<GeomDataAPI_Point> anOrigin = std::dynamic_pointer_cast<GeomDataAPI_Point>(
+        aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+    std::shared_ptr<GeomDataAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+        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<GeomAPI_Pln>(new GeomAPI_Pln(aA, aB, aC, aD));
+      }
     }
   }
   return aPlane;
index 6680aef33008ad4a073d0ed3e3e6b7eebdc207f5..452e07401f313c26d1d867ccaf2f0182f2b86f06 100644 (file)
@@ -129,21 +129,23 @@ std::shared_ptr<ModelAPI_FeatureStateMessage> SketchPlugin_Plugin
       std::dynamic_pointer_cast<SketchPlugin_Sketch>(theFeature);
   if (aSketchFeature.get()) {
     std::shared_ptr<ModelAPI_Data> aData = aSketchFeature->data();
-    std::shared_ptr<GeomDataAPI_Dir> aNormal =
-      std::dynamic_pointer_cast<GeomDataAPI_Dir>(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<GeomDataAPI_Dir> aNormal =
+        std::dynamic_pointer_cast<GeomDataAPI_Dir>(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;
 }