From 6e7b39b6ae7c905f289c58b22ab572c4c25d5ff4 Mon Sep 17 00:00:00 2001 From: Artem Zhidkov Date: Thu, 26 Mar 2020 10:00:48 +0300 Subject: [PATCH] Issue #18905: SIGSEGV when edit a sketch if a change sketch plane has been aborted before --- src/GeomData/GeomData_Dir.cpp | 10 ++++++++++ src/GeomData/GeomData_Dir.h | 3 +++ src/SketcherPrs/SketcherPrs_PositionMgr.cpp | 3 ++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/GeomData/GeomData_Dir.cpp b/src/GeomData/GeomData_Dir.cpp index 23c7ce1c4..07ed1e0d6 100644 --- a/src/GeomData/GeomData_Dir.cpp +++ b/src/GeomData/GeomData_Dir.cpp @@ -82,3 +82,13 @@ void GeomData_Dir::reinit() myIsInitialized = true; } } + +bool GeomData_Dir::isInitialized() +{ + // Check once again the direction is initialized. + // Use case (bos #18905): draw a sketch, click "Change sketch plane", then abort it. + // myIsInitialized value is dropped to false, thus recheck. + if (!myIsInitialized) + myIsInitialized = myLab.FindAttribute(TDataStd_RealArray::GetID(), myCoords) == Standard_True; + return ModelAPI_Attribute::isInitialized(); +} diff --git a/src/GeomData/GeomData_Dir.h b/src/GeomData/GeomData_Dir.h index 1cc7f2ff9..bb4b52abb 100644 --- a/src/GeomData/GeomData_Dir.h +++ b/src/GeomData/GeomData_Dir.h @@ -54,6 +54,9 @@ class GeomData_Dir : public GeomDataAPI_Dir /// Returns the coordinates of this attribute GEOMDATA_EXPORT virtual std::shared_ptr xyz(); + /// Returns \c ture if the direction is initialized + GEOMDATA_EXPORT virtual bool isInitialized(); + protected: /// Initializes attributes GEOMDATA_EXPORT GeomData_Dir(TDF_Label& theLabel); diff --git a/src/SketcherPrs/SketcherPrs_PositionMgr.cpp b/src/SketcherPrs/SketcherPrs_PositionMgr.cpp index eb87e2884..81b5018b7 100644 --- a/src/SketcherPrs/SketcherPrs_PositionMgr.cpp +++ b/src/SketcherPrs/SketcherPrs_PositionMgr.cpp @@ -260,7 +260,8 @@ gp_Pnt SketcherPrs_PositionMgr::getPosition(ObjectPtr theShape, // Compute shifting vector for a one symbol gp_Vec aShift = aVec1.Crossed(thePrs->plane()->normal()->impl()); - aShift.Normalize(); + if (aShift.SquareMagnitude() > Precision::SquareConfusion()) + aShift.Normalize(); aShift.Multiply(theStep * 0.8); // Shift the position coordinate according to position index -- 2.39.2