From e35a042c2d59fc704286e1775df7240cd75a63bd Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 17 Nov 2011 10:31:04 +0000 Subject: [PATCH] + 0000478: Segfault on insert part into 2D drawing (workaround) git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5144 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d --- src/Mod/Drawing/App/CMakeLists.txt | 6 +++ src/Mod/Drawing/App/FeatureProjection.cpp | 60 +++++++++++++---------- src/Mod/Drawing/App/ProjectionAlgos.cpp | 18 +++++-- src/Mod/Part/App/CMakeLists.txt | 4 +- 4 files changed, 54 insertions(+), 34 deletions(-) diff --git a/src/Mod/Drawing/App/CMakeLists.txt b/src/Mod/Drawing/App/CMakeLists.txt index e0c139b5e..0bc121307 100644 --- a/src/Mod/Drawing/App/CMakeLists.txt +++ b/src/Mod/Drawing/App/CMakeLists.txt @@ -60,6 +60,12 @@ if(MSVC) ADD_MSVC_PRECOMPILED_HEADER("PreCompiled.h" "PreCompiled.cpp" Drawing_CPP_SRCS) endif(MSVC) +# Set special compiler flag to convert a SIGSEV into an exception +# to handle issue #0000478. +IF(MSVC) +SET_SOURCE_FILES_PROPERTIES(ProjectionAlgos.cpp PROPERTIES COMPILE_FLAGS "/EHa") +ENDIF(MSVC) + add_library(Drawing SHARED ${Drawing_SRCS} ${Features_SRCS} ${DrawingAlgos_SRCS}) target_link_libraries(Drawing ${Drawing_LIBS}) fc_copy_script("Mod/Drawing" "Drawing" Init.py) diff --git a/src/Mod/Drawing/App/FeatureProjection.cpp b/src/Mod/Drawing/App/FeatureProjection.cpp index 1c95b69b6..a0905952c 100644 --- a/src/Mod/Drawing/App/FeatureProjection.cpp +++ b/src/Mod/Drawing/App/FeatureProjection.cpp @@ -77,33 +77,39 @@ App::DocumentObjectExecReturn *FeatureProjection::execute(void) if (shape.IsNull()) return new App::DocumentObjectExecReturn("Linked shape object is empty"); - const Base::Vector3f& dir = Direction.getValue(); - Drawing::ProjectionAlgos alg(shape, dir); + try { + const Base::Vector3f& dir = Direction.getValue(); + Drawing::ProjectionAlgos alg(shape, dir); - TopoDS_Compound comp; - BRep_Builder builder; - builder.MakeCompound(comp); - if (!alg.V.IsNull() && VCompound.getValue()) - builder.Add(comp, alg.V); - if (!alg.V1.IsNull() && Rg1LineVCompound.getValue()) - builder.Add(comp, alg.V1); - if (!alg.VN.IsNull() && RgNLineVCompound.getValue()) - builder.Add(comp, alg.VN); - if (!alg.VO.IsNull() && OutLineVCompound.getValue()) - builder.Add(comp, alg.VO); - if (!alg.VI.IsNull() && IsoLineVCompound.getValue()) - builder.Add(comp, alg.VI); - if (!alg.H.IsNull() && HCompound.getValue()) - builder.Add(comp, alg.H); - if (!alg.H1.IsNull() && Rg1LineHCompound.getValue()) - builder.Add(comp, alg.H1); - if (!alg.HN.IsNull() && RgNLineHCompound.getValue()) - builder.Add(comp, alg.HN); - if (!alg.HO.IsNull() && OutLineHCompound.getValue()) - builder.Add(comp, alg.HO); - if (!alg.HI.IsNull() && IsoLineHCompound.getValue()) - builder.Add(comp, alg.HI); + TopoDS_Compound comp; + BRep_Builder builder; + builder.MakeCompound(comp); + if (!alg.V.IsNull() && VCompound.getValue()) + builder.Add(comp, alg.V); + if (!alg.V1.IsNull() && Rg1LineVCompound.getValue()) + builder.Add(comp, alg.V1); + if (!alg.VN.IsNull() && RgNLineVCompound.getValue()) + builder.Add(comp, alg.VN); + if (!alg.VO.IsNull() && OutLineVCompound.getValue()) + builder.Add(comp, alg.VO); + if (!alg.VI.IsNull() && IsoLineVCompound.getValue()) + builder.Add(comp, alg.VI); + if (!alg.H.IsNull() && HCompound.getValue()) + builder.Add(comp, alg.H); + if (!alg.H1.IsNull() && Rg1LineHCompound.getValue()) + builder.Add(comp, alg.H1); + if (!alg.HN.IsNull() && RgNLineHCompound.getValue()) + builder.Add(comp, alg.HN); + if (!alg.HO.IsNull() && OutLineHCompound.getValue()) + builder.Add(comp, alg.HO); + if (!alg.HI.IsNull() && IsoLineHCompound.getValue()) + builder.Add(comp, alg.HI); - Shape.setValue(comp); - return App::DocumentObject::StdReturn; + Shape.setValue(comp); + return App::DocumentObject::StdReturn; + } + catch (Standard_Failure) { + Handle_Standard_Failure e = Standard_Failure::Caught(); + return new App::DocumentObjectExecReturn(e->GetMessageString()); + } } diff --git a/src/Mod/Drawing/App/ProjectionAlgos.cpp b/src/Mod/Drawing/App/ProjectionAlgos.cpp index 5d9401254..cb82c3e8e 100644 --- a/src/Mod/Drawing/App/ProjectionAlgos.cpp +++ b/src/Mod/Drawing/App/ProjectionAlgos.cpp @@ -119,11 +119,19 @@ void ProjectionAlgos::execute(void) Handle( HLRBRep_Algo ) brep_hlr = new HLRBRep_Algo; brep_hlr->Add(Input); - gp_Ax2 transform(gp_Pnt(0,0,0),gp_Dir(Direction.x,Direction.y,Direction.z)); - HLRAlgo_Projector projector( transform ); - brep_hlr->Projector(projector); - brep_hlr->Update(); - brep_hlr->Hide(); + try { +#if defined(__GNUC__) && defined (FC_OS_LINUX) + Base::SignalException se; +#endif + gp_Ax2 transform(gp_Pnt(0,0,0),gp_Dir(Direction.x,Direction.y,Direction.z)); + HLRAlgo_Projector projector( transform ); + brep_hlr->Projector(projector); + brep_hlr->Update(); + brep_hlr->Hide(); + } + catch (...) { + Standard_Failure::Raise("Fatal error occurred while projecting shape"); + } // extracting the result sets: HLRBRep_HLRToShape shapes( brep_hlr ); diff --git a/src/Mod/Part/App/CMakeLists.txt b/src/Mod/Part/App/CMakeLists.txt index f430d49a3..cad3395a4 100644 --- a/src/Mod/Part/App/CMakeLists.txt +++ b/src/Mod/Part/App/CMakeLists.txt @@ -230,8 +230,8 @@ SET(Part_SRCS ) SET(Part_Scripts - Init.py - TestPartApp.py + Init.py + TestPartApp.py MakeBottle.py )