]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #3074: SIGSEGV when changing sketch plane
authorazv <azv@opencascade.com>
Wed, 30 Oct 2019 10:40:10 +0000 (13:40 +0300)
committerazv <azv@opencascade.com>
Wed, 30 Oct 2019 10:40:10 +0000 (13:40 +0300)
Do not update the presentation if plane is not selected yet.

src/SketcherPrs/SketcherPrs_Collinear.cpp
src/SketcherPrs/SketcherPrs_Middle.cpp
src/SketcherPrs/SketcherPrs_Mirror.cpp
src/SketcherPrs/SketcherPrs_Parallel.cpp
src/SketcherPrs/SketcherPrs_Perpendicular.cpp
src/SketcherPrs/SketcherPrs_PositionMgr.h
src/SketcherPrs/SketcherPrs_Rigid.cpp
src/SketcherPrs/SketcherPrs_Transformation.cpp

index 90e5d1b0e89d80980b761c6e9174150c2a5ae3f3..6b8ce9c80cfbbc00fd3d26677d75fa97ecadec41 100644 (file)
@@ -38,18 +38,18 @@ SketcherPrs_Collinear::SketcherPrs_Collinear(ModelAPI_Feature* theConstraint,
 }
 
 bool SketcherPrs_Collinear::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
-                                         const std::shared_ptr<GeomAPI_Ax3>&/* thePlane*/)
+                                         const std::shared_ptr<GeomAPI_Ax3>& thePlane)
 {
   bool aReadyToDisplay = false;
-
-  ObjectPtr aObj1 =
-    SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_A());
-  ObjectPtr aObj2 =
-    SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_B());
-
-  aReadyToDisplay = SketcherPrs_Tools::getShape(aObj1).get() != NULL &&
-                    SketcherPrs_Tools::getShape(aObj2).get() != NULL;
-
+  if (thePlane) {
+    ObjectPtr aObj1 =
+      SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_A());
+    ObjectPtr aObj2 =
+      SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_B());
+
+    aReadyToDisplay = SketcherPrs_Tools::getShape(aObj1).get() != NULL &&
+                      SketcherPrs_Tools::getShape(aObj2).get() != NULL;
+  }
   return aReadyToDisplay;
 }
 
index 67326f1561c3dc0d9a09686acac4b8f5aa0b4af7..0352b704df47867c6b74417637b78692376827fa 100644 (file)
@@ -38,20 +38,20 @@ SketcherPrs_Middle::SketcherPrs_Middle(ModelAPI_Feature* theConstraint,
 }
 
 bool SketcherPrs_Middle::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
-                                         const std::shared_ptr<GeomAPI_Ax3>&/* thePlane*/)
+                                         const std::shared_ptr<GeomAPI_Ax3>& thePlane)
 {
   bool aReadyToDisplay = false;
-
-  ObjectPtr aObj1 =
-    SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_A());
-  ObjectPtr aObj2 =
-    SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_B());
-
-  // one object is a feature Line, other object is a point result. We check shape of point result
-  aReadyToDisplay = aObj1.get() && aObj2.get() &&
-                    (SketcherPrs_Tools::getShape(aObj1).get() != NULL ||
-                     SketcherPrs_Tools::getShape(aObj2).get() != NULL);
-
+  if (thePlane) {
+    ObjectPtr aObj1 =
+      SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_A());
+    ObjectPtr aObj2 =
+      SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_B());
+
+    // one object is a feature Line, other object is a point result. We check shape of point result
+    aReadyToDisplay = aObj1.get() && aObj2.get() &&
+                      (SketcherPrs_Tools::getShape(aObj1).get() != NULL ||
+                       SketcherPrs_Tools::getShape(aObj2).get() != NULL);
+  }
   return aReadyToDisplay;
 }
 
index eb3b12c495857de7ebd0b9ce1fb232ba8fe1ab65..c66ced3ebc1031c61ff4301f1f79094c20e6330e 100644 (file)
@@ -40,9 +40,11 @@ SketcherPrs_Mirror::SketcherPrs_Mirror(ModelAPI_Feature* theConstraint,
 }
 
 bool SketcherPrs_Mirror::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
-                                          const std::shared_ptr<GeomAPI_Ax3>&/* thePlane*/)
+                                          const std::shared_ptr<GeomAPI_Ax3>& thePlane)
 {
   bool aReadyToDisplay = false;
+  if (!thePlane)
+    return aReadyToDisplay;
 
   // Get axis of mirror
   ObjectPtr aAxisObj =
index 254c562b1928d30ece2aa7a09baac83f2c7c6f5b..8c631b0cf9f80b3c3c8ec8550f459c247cc2901d 100644 (file)
@@ -39,17 +39,18 @@ SketcherPrs_Parallel::SketcherPrs_Parallel(ModelAPI_Feature* theConstraint,
 }
 
 bool SketcherPrs_Parallel::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
-                                            const std::shared_ptr<GeomAPI_Ax3>&/* thePlane*/)
+                                            const std::shared_ptr<GeomAPI_Ax3>& thePlane)
 {
   bool aReadyToDisplay = false;
-
-  ObjectPtr aObj1 =
-    SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_A());
-  ObjectPtr aObj2 =
-    SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_B());
-
-  aReadyToDisplay = SketcherPrs_Tools::getShape(aObj1).get() != NULL &&
-                    SketcherPrs_Tools::getShape(aObj2).get() != NULL;
+  if (thePlane) {
+    ObjectPtr aObj1 =
+      SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_A());
+    ObjectPtr aObj2 =
+      SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_B());
+
+    aReadyToDisplay = SketcherPrs_Tools::getShape(aObj1).get() != NULL &&
+                      SketcherPrs_Tools::getShape(aObj2).get() != NULL;
+  }
   return aReadyToDisplay;
 }
 
index acd166cb9343a2fa375c219f22e53c6f9605e4c8..1a801a165a058927ff107c3385a12d541b74e21f 100644 (file)
@@ -43,17 +43,18 @@ SketcherPrs_Perpendicular::SketcherPrs_Perpendicular(ModelAPI_Feature* theConstr
 }
 
 bool SketcherPrs_Perpendicular::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
-                                                 const std::shared_ptr<GeomAPI_Ax3>&/* thePlane*/)
+                                                 const std::shared_ptr<GeomAPI_Ax3>& thePlane)
 {
   bool aReadyToDisplay = false;
-
-  ObjectPtr aObj1 =
-    SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_A());
-  ObjectPtr aObj2 =
-    SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_B());
-
-  aReadyToDisplay = SketcherPrs_Tools::getShape(aObj1).get() != NULL &&
-                    SketcherPrs_Tools::getShape(aObj2).get() != NULL;
+  if (thePlane) {
+    ObjectPtr aObj1 =
+      SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_A());
+    ObjectPtr aObj2 =
+      SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_B());
+
+    aReadyToDisplay = SketcherPrs_Tools::getShape(aObj1).get() != NULL &&
+                      SketcherPrs_Tools::getShape(aObj2).get() != NULL;
+  }
   return aReadyToDisplay;
 }
 
index a0e8fe137629328a2082bb7ba2159180720cb426..05e916aacd2d145a7ec67d04976ce63f8d569d84 100644 (file)
 * A class Position Manager which manages position of constraints symbols along a source object line.
 * it expects that symbol icons have size 16x16 px
 */
-class SKETCHERPRS_EXPORT SketcherPrs_PositionMgr
+class SketcherPrs_PositionMgr
 {
 public:
   /// Returns current instance of position manager
-  static SketcherPrs_PositionMgr* get();
+  SKETCHERPRS_EXPORT static SketcherPrs_PositionMgr* get();
 
   /// Returns position of symbol for the given presentation
   /// \param theLine constrained object
   /// \param thePrs a presentation of constraint
   /// \param theStep step between symbols
-  gp_Pnt getPosition(ObjectPtr theLine, const SketcherPrs_SymbolPrs* thePrs,
-                     double theStep = 20, GeomPointPtr thePnt = GeomPointPtr());
+  SKETCHERPRS_EXPORT gp_Pnt getPosition(ObjectPtr theLine, const SketcherPrs_SymbolPrs* thePrs,
+                                        double theStep = 20, GeomPointPtr thePnt = GeomPointPtr());
 
   /// Deletes constraint object from internal structures. Has to be called on constraint delete.
   /// \param thePrs a constraint presentation
-  void deleteConstraint(const SketcherPrs_SymbolPrs* thePrs);
+  SKETCHERPRS_EXPORT void deleteConstraint(const SketcherPrs_SymbolPrs* thePrs);
 
   /// Cleares all stored positions for all constraints
   void clearAll()  { myShapes.clear(); myPntShapes.clear(); }
index d552f06f16fee4b4a679068319ff6b5e1b4b6d63..d704e2e1665e1e9ffe8a293f1a4971a6828bbefb 100644 (file)
@@ -59,6 +59,8 @@ bool SketcherPrs_Rigid::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
                                          const std::shared_ptr<GeomAPI_Ax3>& thePlane)
 {
   bool aReadyToDisplay = false;
+  if (!thePlane)
+    return aReadyToDisplay;
 
   std::shared_ptr<ModelAPI_Data> aData = theConstraint->data();
   std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
index 53be1f2fe30673992c093ddbadd1b7c8bfebf3a9..82e375f0f989fc0b401f1006eff3d8eb9373f12d 100644 (file)
@@ -48,9 +48,11 @@ SketcherPrs_Transformation::SketcherPrs_Transformation(ModelAPI_Feature* theCons
 }
 
 bool SketcherPrs_Transformation::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
-                                                  const std::shared_ptr<GeomAPI_Ax3>&/* thePlane*/)
+                                                  const std::shared_ptr<GeomAPI_Ax3>& thePlane)
 {
   bool aReadyToDisplay = false;
+  if (!thePlane)
+    return aReadyToDisplay;
 
   std::shared_ptr<ModelAPI_Data> aData = theConstraint->data();
   // Get transformated objects list