Handle boost exceptions. (From Coverity scan.)

This commit is contained in:
Jeff Young 2020-01-11 00:04:01 +00:00
parent 33da81cd27
commit 7bb9551801
9 changed files with 316 additions and 319 deletions

View File

@ -80,13 +80,6 @@ static const wxChar UsePinFunction[] = wxT( "UsePinFunction" );
*/
static const wxChar RealtimeConnectivity[] = wxT( "RealtimeConnectivity" );
/**
* Allow legacy canvas to be shown in GTK3. Legacy canvas is generally pretty
* broken, but this avoids code in an ifdef where it could become broken
* on other platforms
*/
static const wxChar AllowLegacyCanvasInGtk3[] = wxT( "AllowLegacyCanvasInGtk3" );
/**
* Configure the coroutine stack size in bytes. This should be allocated in multiples of
* the system page size (n*4096 is generally safe)
@ -172,7 +165,6 @@ ADVANCED_CFG::ADVANCED_CFG()
// then the values will remain as set here.
m_EnableUsePadProperty = false;
m_EnableUsePinFunction = false;
m_allowLegacyCanvasInGtk3 = false;
m_realTimeConnectivity = true;
m_coroutineStackSize = AC_STACK::default_stack;
@ -208,21 +200,25 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
{
PARAM_CFG_ARRAY configParams;
try
{
configParams.push_back(
new PARAM_CFG_BOOL( true, AC_KEYS::UsePadProperty, &m_EnableUsePadProperty, false ) );
configParams.push_back(
new PARAM_CFG_BOOL( true, AC_KEYS::UsePinFunction, &m_EnableUsePinFunction, false ) );
configParams.push_back( new PARAM_CFG_BOOL(
true, AC_KEYS::AllowLegacyCanvasInGtk3, &m_allowLegacyCanvasInGtk3, false ) );
configParams.push_back(
new PARAM_CFG_BOOL( true, AC_KEYS::RealtimeConnectivity, &m_realTimeConnectivity, false ) );
configParams.push_back(
new PARAM_CFG_INT( true, AC_KEYS::CoroutineStackSize, &m_coroutineStackSize,
AC_STACK::default_stack, AC_STACK::min_stack, AC_STACK::max_stack ) );
}
catch( boost::bad_pointer& )
{
// Out of memory? Ship's going down anyway....
}
wxConfigLoadSetups( &aCfg, configParams );
@ -230,15 +226,3 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
}
bool ADVANCED_CFG::AllowLegacyCanvas() const
{
// default is to allow
bool allow = true;
// on GTK3, check the config
#ifdef __WXGTK3__
allow = m_allowLegacyCanvasInGtk3;
#endif
return allow;
}

View File

@ -430,11 +430,18 @@ void PART_LIBS::LibNamesAndPaths( PROJECT* aProject, bool doSave,
PARAM_CFG_ARRAY ca;
try
{
if( aPaths )
ca.push_back( new PARAM_CFG_FILENAME( "LibDir", aPaths ) );
if( aNames )
ca.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ), aNames, GROUP_SCH_LIBS ) );
}
catch( boost::bad_pointer& )
{
// Out of memory? Ship's going down anyway....
}
if( doSave )
{

View File

@ -187,6 +187,8 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetProjectFileParameters()
if( !m_projectFileParams.empty() )
return m_projectFileParams;
try
{
m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "PageLayoutDescrFile" ),
&BASE_SCREEN::m_PageLayoutDescrFileName ) );
@ -226,6 +228,11 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetProjectFileParameters()
m_projectFileParams.push_back( new PARAM_CFG_BOOL( wxT( "ERC_CheckBusToNetConflicts" ),
&m_ercSettings.check_bus_to_net_conflicts, true ) );
}
catch( boost::bad_pointer& )
{
// Out of memory? Ship's going down anyway....
}
return m_projectFileParams;
}
@ -343,6 +350,8 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetConfigurationSettings()
if( !m_configSettings.empty() )
return m_configSettings;
try
{
m_configSettings.push_back( new PARAM_CFG_BOOL( true, ShowPageLimitsEntry,
&m_showPageLimits, true ) );
m_configSettings.push_back( new PARAM_CFG_INT(
@ -361,6 +370,12 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetConfigurationSettings()
m_configSettings.push_back( new PARAM_CFG_BOOL( true, showSheetFileNameCaseSensitivityDlg,
&m_showSheetFileNameCaseSensitivityDlg,
true ) );
}
catch( boost::bad_pointer& )
{
// Out of memory? Ship's going down anyway....
}
return m_configSettings;
}

View File

@ -554,21 +554,11 @@ void SCH_TEXT::GetMsgPanelInfo( EDA_UNITS aUnits, MSG_PANEL_ITEMS& aList )
switch( GetLabelSpinStyle() )
{
case LABEL_SPIN_STYLE::LEFT:
msg = _( "Horizontal left" );
break;
case LABEL_SPIN_STYLE::UP:
msg = _( "Vertical up" );
break;
case LABEL_SPIN_STYLE::RIGHT:
msg = _( "Horizontal right" );
break;
case LABEL_SPIN_STYLE::BOTTOM:
msg = _( "Vertical down" );
break;
default:
msg = wxT( "???" );
break;
case LABEL_SPIN_STYLE::LEFT: msg = _( "Horizontal left" ); break;
case LABEL_SPIN_STYLE::UP: msg = _( "Vertical up" ); break;
case LABEL_SPIN_STYLE::RIGHT: msg = _( "Horizontal right" ); break;
case LABEL_SPIN_STYLE::BOTTOM: msg = _( "Vertical down" ); break;
default: msg = wxT( "???" ); break;
}
aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), msg, BROWN ) );
@ -589,24 +579,12 @@ void SCH_TEXT::GetMsgPanelInfo( EDA_UNITS aUnits, MSG_PANEL_ITEMS& aList )
{
switch( GetShape() )
{
case PINSHEETLABEL_SHAPE::PS_INPUT:
msg = _( "Input" );
break;
case PINSHEETLABEL_SHAPE::PS_OUTPUT:
msg = _( "Output" );
break;
case PINSHEETLABEL_SHAPE::PS_BIDI:
msg = _( "Bidirectional" );
break;
case PINSHEETLABEL_SHAPE::PS_TRISTATE:
msg = _( "Tri-State" );
break;
case PINSHEETLABEL_SHAPE::PS_UNSPECIFIED:
msg = _( "Passive" );
break;
default:
msg = wxT( "???" );
break;
case PINSHEETLABEL_SHAPE::PS_INPUT: msg = _( "Input" ); break;
case PINSHEETLABEL_SHAPE::PS_OUTPUT: msg = _( "Output" ); break;
case PINSHEETLABEL_SHAPE::PS_BIDI: msg = _( "Bidirectional" ); break;
case PINSHEETLABEL_SHAPE::PS_TRISTATE: msg = _( "Tri-State" ); break;
case PINSHEETLABEL_SHAPE::PS_UNSPECIFIED: msg = _( "Passive" ); break;
default: msg = wxT( "???" ); break;
}
aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, BLUE ) );

View File

@ -52,6 +52,8 @@ PARAM_CFG_ARRAY& GERBVIEW_FRAME::GetConfigurationSettings()
if( !m_configSettings.empty() )
return m_configSettings;
try
{
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "DrawModeOption" ),
&m_displayMode, 2, 0, 2 ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR(
@ -72,6 +74,11 @@ PARAM_CFG_ARRAY& GERBVIEW_FRAME::GetConfigurationSettings()
m_configSettings.push_back( new PARAM_CFG_BOOL(
true, wxT( "DisplayPolarCoordinates" ),
&m_PolarCoords, false ) );
}
catch( boost::bad_pointer& )
{
// Out of memory? Ship's going down anyway....
}
// Default colors for layers 0 to 31
static const COLOR4D color_default[] = {

View File

@ -88,21 +88,6 @@ public:
*/
int m_coroutineStackSize;
/**
* Helper to determine if legacy canvas is allowed (according to platform
* and config)
* @return true if legacy canvas should be shown
*/
bool AllowLegacyCanvas() const;
private:
/*
* These settings are private, as there is extra logic provide by helper
* functions above.
*/
bool m_allowLegacyCanvasInGtk3;
private:
ADVANCED_CFG();

View File

@ -531,6 +531,8 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS() :
// values are saved in mm
void BOARD_DESIGN_SETTINGS::AppendConfigs( BOARD* aBoard, PARAM_CFG_ARRAY* aResult )
{
try
{
aResult->push_back( new PARAM_CFG_LAYERS( aBoard ) );
aResult->push_back( new PARAM_CFG_BOOL( wxT( "AllowMicroVias" ),
@ -699,6 +701,11 @@ void BOARD_DESIGN_SETTINGS::AppendConfigs( BOARD* aBoard, PARAM_CFG_ARRAY* aResu
aResult->push_back( new PARAM_CFG_DOUBLE( wxT( "SolderPasteRatio" ),
&m_SolderPasteMarginRatio,
DEFAULT_SOLDERPASTE_RATIO, -0.5, 1.0 ) );
}
catch( boost::bad_pointer& )
{
// Out of memory? Ship's going down anyway....
}
}

View File

@ -540,6 +540,8 @@ void D_PAD::AppendConfigs( PARAM_CFG_ARRAY* aResult )
// Parameters stored in config are only significant parameters
// for a template.
// So not all parameters are stored, just few.
try
{
aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "PadDrill" ),
&m_Drill.x,
Millimeter2iu( 0.6 ),
@ -563,6 +565,11 @@ void D_PAD::AppendConfigs( PARAM_CFG_ARRAY* aResult )
Millimeter2iu( 1.4 ),
Millimeter2iu( 0.1 ), Millimeter2iu( 20.0 ),
NULL, MM_PER_IU ) );
}
catch( boost::bad_pointer& )
{
// Out of memory? Ship's going down anyway....
}
}

View File

@ -34,6 +34,8 @@ PCB_GENERAL_SETTINGS::PCB_GENERAL_SETTINGS( FRAME_T aFrameType ) :
m_frameType( aFrameType ),
m_colorsSettings( aFrameType )
{
try
{
switch( m_frameType )
{
case FRAME_PCB_EDITOR:
@ -59,6 +61,11 @@ PCB_GENERAL_SETTINGS::PCB_GENERAL_SETTINGS( FRAME_T aFrameType ) :
default:
break;
}
}
catch( boost::bad_pointer& )
{
// Out of memory? Ship's going down anyway....
}
}