]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #18905: SIGSEGV when edit a sketch if a change sketch plane has been aborted...
authorArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Thu, 26 Mar 2020 07:00:48 +0000 (10:00 +0300)
committerArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Thu, 26 Mar 2020 07:00:48 +0000 (10:00 +0300)
src/GeomData/GeomData_Dir.cpp
src/GeomData/GeomData_Dir.h
src/SketcherPrs/SketcherPrs_PositionMgr.cpp

index 23c7ce1c4141c879640569ab080848dd5b811f93..07ed1e0d6fdaaf36dc042a152d5715dc97133703 100644 (file)
@@ -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();
+}
index 1cc7f2ff92a0887c99e691ec294f50ceefdeb38c..bb4b52abb8d55ee3b4fc393f5b774e39544e7517 100644 (file)
@@ -54,6 +54,9 @@ class GeomData_Dir : public GeomDataAPI_Dir
   /// Returns the coordinates of this attribute
   GEOMDATA_EXPORT virtual std::shared_ptr<GeomAPI_XYZ> xyz();
 
+  /// Returns \c ture if the direction is initialized
+  GEOMDATA_EXPORT virtual bool isInitialized();
+
  protected:
   /// Initializes attributes
   GEOMDATA_EXPORT GeomData_Dir(TDF_Label& theLabel);
index eb87e28847692f9538df90733cdd5118db86f5af..81b5018b76e2865f6d7e45c05d256e8978b8a015 100644 (file)
@@ -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<gp_Dir>());
-  aShift.Normalize();
+  if (aShift.SquareMagnitude() > Precision::SquareConfusion())
+    aShift.Normalize();
   aShift.Multiply(theStep * 0.8);
 
   // Shift the position coordinate according to position index