From 5852d3de510d4e69f444b821ca484cbe76d3be95 Mon Sep 17 00:00:00 2001 From: apo Date: Fri, 3 Mar 2006 14:25:21 +0000 Subject: [PATCH] To improve SALOME signal handling. Connected to the following bugs. Bug IPAL11670 CRASH after trying to import "polygones.med" and "recall_bord.med". Bug PAL11170 SIGSEGV when "extrusion along a path" gives no result --- src/StdMeshers/StdMeshers_Distribution.cxx | 29 +++++--------- .../StdMeshers_NumberOfSegments.cxx | 25 +++--------- .../StdMeshersGUI_DistrPreview.cxx | 38 ++++++------------- 3 files changed, 27 insertions(+), 65 deletions(-) diff --git a/src/StdMeshers/StdMeshers_Distribution.cxx b/src/StdMeshers/StdMeshers_Distribution.cxx index 93858296b..01fc5c6f6 100644 --- a/src/StdMeshers/StdMeshers_Distribution.cxx +++ b/src/StdMeshers/StdMeshers_Distribution.cxx @@ -27,10 +27,8 @@ // $Header$ #include "StdMeshers_Distribution.hxx" -#include -#include -#include -#include +#include "CASCatch_CatchSignals.hxx" + #include #include @@ -46,7 +44,6 @@ Function::~Function() bool Function::value( const double, double& f ) const { CASCatch_CatchSignals aCatchSignals; - aCatchSignals.Activate(); bool ok = true; if( myConv==0 ) @@ -55,10 +52,9 @@ bool Function::value( const double, double& f ) const { f = pow( 10, f ); } - CASCatch_CATCH(CASCatch_Failure) + CASCatch_CATCH(Standard_Failure) { - aCatchSignals.Deactivate(); - Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught(); + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); f = 0.0; ok = false; } @@ -175,7 +171,6 @@ FunctionExpr::FunctionExpr( const char* str, const int conv ) myValues( 1, 1 ) { CASCatch_CatchSignals aCatchSignals; - aCatchSignals.Activate(); bool ok = true; CASCatch_TRY @@ -183,13 +178,11 @@ FunctionExpr::FunctionExpr( const char* str, const int conv ) myExpr = ExprIntrp_GenExp::Create(); myExpr->Process( ( Standard_CString )str ); } - CASCatch_CATCH(CASCatch_Failure) + CASCatch_CATCH(Standard_Failure) { - aCatchSignals.Deactivate(); - Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught(); + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); ok = false; } - aCatchSignals.Deactivate(); if( !ok || !myExpr->IsDone() ) myExpr.Nullify(); @@ -214,23 +207,19 @@ bool FunctionExpr::value( const double t, double& f ) const if( myExpr.IsNull() ) return false; - OSD::SetSignal( true ); CASCatch_CatchSignals aCatchSignals; - aCatchSignals.Activate(); ( ( TColStd_Array1OfReal& )myValues ).ChangeValue( 1 ) = t; bool ok = true; CASCatch_TRY { f = myExpr->Expression()->Evaluate( myVars, myValues ); } - CASCatch_CATCH(CASCatch_Failure) { - aCatchSignals.Deactivate(); - Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught(); + CASCatch_CATCH(Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); f = 0.0; ok = false; } - aCatchSignals.Deactivate(); ok = Function::value( t, f ) && ok; return ok; } @@ -244,7 +233,7 @@ double FunctionExpr::integral( const double a, const double b ) const if( _int.IsDone() ) res = _int.Value(); } - CASCatch_CATCH(CASCatch_Failure) + CASCatch_CATCH(Standard_Failure) { res = 0.0; MESSAGE( "Exception in integral calculating" ); diff --git a/src/StdMeshers/StdMeshers_NumberOfSegments.cxx b/src/StdMeshers/StdMeshers_NumberOfSegments.cxx index 139ea22e6..c5eef6700 100644 --- a/src/StdMeshers/StdMeshers_NumberOfSegments.cxx +++ b/src/StdMeshers/StdMeshers_NumberOfSegments.cxx @@ -33,20 +33,16 @@ #include "SMESHDS_SubMesh.hxx" #include "SMESH_Mesh.hxx" -#include -#include -#include +#include "CASCatch_CatchSignals.hxx" + #include #include #include -#include #include #include #include #include -#include - using namespace std; const double PRECISION = 1e-7; @@ -216,10 +212,7 @@ void StdMeshers_NumberOfSegments::SetTableFunction(const std::vector& ta double prev = -PRECISION; bool isSame = table.size() == _table.size(); - OSD::SetSignal( true ); CASCatch_CatchSignals aCatchSignals; - aCatchSignals.Activate(); - bool pos = false; for (i=0; i < table.size()/2; i++) { double par = table[i*2]; @@ -230,10 +223,9 @@ void StdMeshers_NumberOfSegments::SetTableFunction(const std::vector& ta { val = pow( 10.0, val ); } - CASCatch_CATCH(CASCatch_Failure) + CASCatch_CATCH(Standard_Failure) { - aCatchSignals.Deactivate(); - Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught(); + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); throw SALOME_Exception( LOCALIZED( "invalid value")); return; } @@ -258,7 +250,6 @@ void StdMeshers_NumberOfSegments::SetTableFunction(const std::vector& ta } prev = par; } - aCatchSignals.Deactivate(); if( !pos ) throw SALOME_Exception(LOCALIZED("value of table function is not positive")); @@ -320,9 +311,7 @@ bool process( const TCollection_AsciiString& str, int convMode, bool& non_neg, bool& non_zero, bool& singulars, double& sing_point ) { - OSD::SetSignal( true ); CASCatch_CatchSignals aCatchSignals; - aCatchSignals.Activate(); bool parsed_ok = true; Handle( ExprIntrp_GenExp ) myExpr; @@ -331,13 +320,11 @@ bool process( const TCollection_AsciiString& str, int convMode, myExpr = ExprIntrp_GenExp::Create(); myExpr->Process( str.ToCString() ); } - CASCatch_CATCH(CASCatch_Failure) + CASCatch_CATCH(Standard_Failure) { - aCatchSignals.Deactivate(); - Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught(); + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); parsed_ok = false; } - aCatchSignals.Deactivate(); syntax = false; args = false; diff --git a/src/StdMeshersGUI/StdMeshersGUI_DistrPreview.cxx b/src/StdMeshersGUI/StdMeshersGUI_DistrPreview.cxx index 0d66dc53a..075f2345d 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_DistrPreview.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_DistrPreview.cxx @@ -1,11 +1,9 @@ #include "StdMeshersGUI_DistrPreview.h" +#include "CASCatch_CatchSignals.hxx" + #include #include -#include -#include -#include -#include StdMeshersGUI_DistrPreview::StdMeshersGUI_DistrPreview( QWidget* p, StdMeshers::StdMeshers_NumberOfSegments_ptr h ) : QwtPlot( p ), @@ -223,20 +221,16 @@ void StdMeshersGUI_DistrPreview::update() delete[] y; x = y = 0; - OSD::SetSignal( true ); CASCatch_CatchSignals aCatchSignals; - aCatchSignals.Activate(); CASCatch_TRY { replot(); } - CASCatch_CATCH(CASCatch_Failure) + CASCatch_CATCH(Standard_Failure) { - aCatchSignals.Deactivate(); - Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught(); + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); } - aCatchSignals.Deactivate(); } void StdMeshersGUI_DistrPreview::showError() @@ -274,7 +268,6 @@ bool isCorrectArg( const Handle( Expr_GeneralExpression )& expr ) bool StdMeshersGUI_DistrPreview::init( const QString& str ) { CASCatch_CatchSignals aCatchSignals; - aCatchSignals.Activate(); bool parsed_ok = true; CASCatch_TRY @@ -282,13 +275,11 @@ bool StdMeshersGUI_DistrPreview::init( const QString& str ) myExpr = ExprIntrp_GenExp::Create(); myExpr->Process( ( Standard_CString ) str.latin1() ); } - CASCatch_CATCH(CASCatch_Failure) + CASCatch_CATCH(Standard_Failure) { - aCatchSignals.Deactivate(); - Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught(); + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); parsed_ok = false; } - aCatchSignals.Deactivate(); bool syntax = false, args = false; if( parsed_ok && myExpr->IsDone() ) @@ -318,23 +309,20 @@ double StdMeshersGUI_DistrPreview::funcValue( const double t, bool& ok ) double StdMeshersGUI_DistrPreview::calc( bool& ok ) { - OSD::SetSignal( true ); double res = 0.0; CASCatch_CatchSignals aCatchSignals; - aCatchSignals.Activate(); ok = true; CASCatch_TRY { res = myExpr->Expression()->Evaluate( myVars, myValues ); } - CASCatch_CATCH(CASCatch_Failure) { - aCatchSignals.Deactivate(); - Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught(); + CASCatch_CATCH(Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); ok = false; res = 0.0; } - aCatchSignals.Deactivate(); + return res; } @@ -346,7 +334,6 @@ bool StdMeshersGUI_DistrPreview::isDone() const bool StdMeshersGUI_DistrPreview::convert( double& v ) const { CASCatch_CatchSignals aCatchSignals; - aCatchSignals.Activate(); bool ok = true; switch( myConv ) @@ -357,10 +344,9 @@ bool StdMeshersGUI_DistrPreview::convert( double& v ) const { v = pow( 10.0, v ); } - CASCatch_CATCH(CASCatch_Failure) + CASCatch_CATCH(Standard_Failure) { - aCatchSignals.Deactivate(); - Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught(); + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); v = 0.0; ok = false; } @@ -372,6 +358,6 @@ bool StdMeshersGUI_DistrPreview::convert( double& v ) const v = 0; break; } - aCatchSignals.Deactivate(); + return ok; } -- 2.39.2