From: azv Date: Wed, 30 Oct 2019 10:40:10 +0000 (+0300) Subject: Issue #3074: SIGSEGV when changing sketch plane X-Git-Tag: V9_4_0rc1~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a0519cf58c58bbe2f8c3152689bea4cd1fa2a123;p=modules%2Fshaper.git Issue #3074: SIGSEGV when changing sketch plane Do not update the presentation if plane is not selected yet. --- diff --git a/src/SketcherPrs/SketcherPrs_Collinear.cpp b/src/SketcherPrs/SketcherPrs_Collinear.cpp index 90e5d1b0e..6b8ce9c80 100644 --- a/src/SketcherPrs/SketcherPrs_Collinear.cpp +++ b/src/SketcherPrs/SketcherPrs_Collinear.cpp @@ -38,18 +38,18 @@ SketcherPrs_Collinear::SketcherPrs_Collinear(ModelAPI_Feature* theConstraint, } bool SketcherPrs_Collinear::IsReadyToDisplay(ModelAPI_Feature* theConstraint, - const std::shared_ptr&/* thePlane*/) + const std::shared_ptr& 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; } diff --git a/src/SketcherPrs/SketcherPrs_Middle.cpp b/src/SketcherPrs/SketcherPrs_Middle.cpp index 67326f156..0352b704d 100644 --- a/src/SketcherPrs/SketcherPrs_Middle.cpp +++ b/src/SketcherPrs/SketcherPrs_Middle.cpp @@ -38,20 +38,20 @@ SketcherPrs_Middle::SketcherPrs_Middle(ModelAPI_Feature* theConstraint, } bool SketcherPrs_Middle::IsReadyToDisplay(ModelAPI_Feature* theConstraint, - const std::shared_ptr&/* thePlane*/) + const std::shared_ptr& 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; } diff --git a/src/SketcherPrs/SketcherPrs_Mirror.cpp b/src/SketcherPrs/SketcherPrs_Mirror.cpp index eb3b12c49..c66ced3eb 100644 --- a/src/SketcherPrs/SketcherPrs_Mirror.cpp +++ b/src/SketcherPrs/SketcherPrs_Mirror.cpp @@ -40,9 +40,11 @@ SketcherPrs_Mirror::SketcherPrs_Mirror(ModelAPI_Feature* theConstraint, } bool SketcherPrs_Mirror::IsReadyToDisplay(ModelAPI_Feature* theConstraint, - const std::shared_ptr&/* thePlane*/) + const std::shared_ptr& thePlane) { bool aReadyToDisplay = false; + if (!thePlane) + return aReadyToDisplay; // Get axis of mirror ObjectPtr aAxisObj = diff --git a/src/SketcherPrs/SketcherPrs_Parallel.cpp b/src/SketcherPrs/SketcherPrs_Parallel.cpp index 254c562b1..8c631b0cf 100644 --- a/src/SketcherPrs/SketcherPrs_Parallel.cpp +++ b/src/SketcherPrs/SketcherPrs_Parallel.cpp @@ -39,17 +39,18 @@ SketcherPrs_Parallel::SketcherPrs_Parallel(ModelAPI_Feature* theConstraint, } bool SketcherPrs_Parallel::IsReadyToDisplay(ModelAPI_Feature* theConstraint, - const std::shared_ptr&/* thePlane*/) + const std::shared_ptr& 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; } diff --git a/src/SketcherPrs/SketcherPrs_Perpendicular.cpp b/src/SketcherPrs/SketcherPrs_Perpendicular.cpp index acd166cb9..1a801a165 100644 --- a/src/SketcherPrs/SketcherPrs_Perpendicular.cpp +++ b/src/SketcherPrs/SketcherPrs_Perpendicular.cpp @@ -43,17 +43,18 @@ SketcherPrs_Perpendicular::SketcherPrs_Perpendicular(ModelAPI_Feature* theConstr } bool SketcherPrs_Perpendicular::IsReadyToDisplay(ModelAPI_Feature* theConstraint, - const std::shared_ptr&/* thePlane*/) + const std::shared_ptr& 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; } diff --git a/src/SketcherPrs/SketcherPrs_PositionMgr.h b/src/SketcherPrs/SketcherPrs_PositionMgr.h index a0e8fe137..05e916aac 100644 --- a/src/SketcherPrs/SketcherPrs_PositionMgr.h +++ b/src/SketcherPrs/SketcherPrs_PositionMgr.h @@ -36,22 +36,22 @@ * 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(); } diff --git a/src/SketcherPrs/SketcherPrs_Rigid.cpp b/src/SketcherPrs/SketcherPrs_Rigid.cpp index d552f06f1..d704e2e16 100644 --- a/src/SketcherPrs/SketcherPrs_Rigid.cpp +++ b/src/SketcherPrs/SketcherPrs_Rigid.cpp @@ -59,6 +59,8 @@ bool SketcherPrs_Rigid::IsReadyToDisplay(ModelAPI_Feature* theConstraint, const std::shared_ptr& thePlane) { bool aReadyToDisplay = false; + if (!thePlane) + return aReadyToDisplay; std::shared_ptr aData = theConstraint->data(); std::shared_ptr anAttr = diff --git a/src/SketcherPrs/SketcherPrs_Transformation.cpp b/src/SketcherPrs/SketcherPrs_Transformation.cpp index 53be1f2fe..82e375f0f 100644 --- a/src/SketcherPrs/SketcherPrs_Transformation.cpp +++ b/src/SketcherPrs/SketcherPrs_Transformation.cpp @@ -48,9 +48,11 @@ SketcherPrs_Transformation::SketcherPrs_Transformation(ModelAPI_Feature* theCons } bool SketcherPrs_Transformation::IsReadyToDisplay(ModelAPI_Feature* theConstraint, - const std::shared_ptr&/* thePlane*/) + const std::shared_ptr& thePlane) { bool aReadyToDisplay = false; + if (!thePlane) + return aReadyToDisplay; std::shared_ptr aData = theConstraint->data(); // Get transformated objects list