From b0ad779ee4f32146fa6b7655f0e4686dd86fb0da Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Sun, 15 Feb 2015 23:21:52 +0100 Subject: [PATCH] Calming down the Coverity report. --- include/view/view.h | 9 ++++++++- pcbnew/class_board_design_settings.cpp | 2 ++ pcbnew/class_module.cpp | 19 +++++++++++++------ pcbnew/tools/drawing_tool.cpp | 19 ++++++++++--------- pcbnew/tools/drawing_tool.h | 2 +- pcbnew/tools/edit_tool.cpp | 4 +++- pcbnew/tools/module_tools.cpp | 3 ++- pcbnew/tools/pcb_editor_control.cpp | 2 +- pcbnew/tools/pcbnew_control.cpp | 2 +- pcbnew/tools/placement_tool.cpp | 2 +- 10 files changed, 42 insertions(+), 22 deletions(-) diff --git a/include/view/view.h b/include/view/view.h index 9ab7fe9a6a..4fa0db9740 100644 --- a/include/view/view.h +++ b/include/view/view.h @@ -492,7 +492,14 @@ public: { wxASSERT( aLayer < (int) m_layers.size() ); - return m_layers.at( aLayer ).target == TARGET_CACHED; + try + { + return m_layers.at( aLayer ).target == TARGET_CACHED; + } + catch( std::out_of_range ) + { + return false; + } } /** diff --git a/pcbnew/class_board_design_settings.cpp b/pcbnew/class_board_design_settings.cpp index de8a318421..6e11716155 100644 --- a/pcbnew/class_board_design_settings.cpp +++ b/pcbnew/class_board_design_settings.cpp @@ -82,6 +82,8 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS() : m_PcbTextSize = wxSize( DEFAULT_TEXT_PCB_SIZE, DEFAULT_TEXT_PCB_SIZE ); // current Pcb (not module) Text size + m_useCustomTrackVia = false; + m_customTrackWidth = DMils2iu( 100 ); m_TrackMinWidth = DMils2iu( 100 ); // track min value for width (min copper size value) m_ViasMinSize = DMils2iu( 350 ); // vias (not micro vias) min diameter m_ViasMinDrill = DMils2iu( 200 ); // vias (not micro vias) min drill diameter diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index ecf7c45caa..4248cc52db 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -800,14 +800,21 @@ EDA_ITEM* MODULE::Clone() const void MODULE::RunOnChildren( boost::function aFunction ) { - for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) - aFunction( static_cast( pad ) ); + try + { + for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) + aFunction( static_cast( pad ) ); - for( BOARD_ITEM* drawing = m_Drawings; drawing; drawing = drawing->Next() ) - aFunction( drawing ); + for( BOARD_ITEM* drawing = m_Drawings; drawing; drawing = drawing->Next() ) + aFunction( drawing ); - aFunction( static_cast( m_Reference ) ); - aFunction( static_cast( m_Value ) ); + aFunction( static_cast( m_Reference ) ); + aFunction( static_cast( m_Value ) ); + } + catch( boost::bad_function_call& e ) + { + DisplayError( NULL, wxT( "Error running MODULE::RunOnChildren" ) ); + } } diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 7b07b5586b..10b70aefbb 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -52,7 +52,8 @@ #include DRAWING_TOOL::DRAWING_TOOL() : - TOOL_INTERACTIVE( "pcbnew.InteractiveDrawing" ), m_editModules( false ) + TOOL_INTERACTIVE( "pcbnew.InteractiveDrawing" ), m_view( NULL ), + m_controls( NULL ), m_board( NULL ), m_frame( NULL ), m_editModules( false ), m_lineWidth( 1 ) { } @@ -901,7 +902,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, // Init the new item attributes aGraphic->SetShape( (STROKE_T) aShape ); - aGraphic->SetWidth( lineWidth ); + aGraphic->SetWidth( m_lineWidth ); aGraphic->SetStart( wxPoint( aStartingPoint->x, aStartingPoint->y ) ); aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetLayer( layer ); @@ -963,8 +964,8 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, { // Init the new item attributes aGraphic->SetShape( (STROKE_T) aShape ); - lineWidth = getSegmentWidth( layer ); - aGraphic->SetWidth( lineWidth ); + m_lineWidth = getSegmentWidth( layer ); + aGraphic->SetWidth( m_lineWidth ); aGraphic->SetStart( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetLayer( layer ); @@ -1012,17 +1013,17 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, else if( evt->IsAction( &COMMON_ACTIONS::incWidth ) ) { - lineWidth += WIDTH_STEP; - aGraphic->SetWidth( lineWidth ); + m_lineWidth += WIDTH_STEP; + aGraphic->SetWidth( m_lineWidth ); updatePreview = true; } else if( evt->IsAction( &COMMON_ACTIONS::decWidth ) ) { - if( lineWidth > (unsigned) WIDTH_STEP ) + if( m_lineWidth > (unsigned) WIDTH_STEP ) { - lineWidth -= WIDTH_STEP; - aGraphic->SetWidth( lineWidth ); + m_lineWidth -= WIDTH_STEP; + aGraphic->SetWidth( m_lineWidth ); updatePreview = true; } } diff --git a/pcbnew/tools/drawing_tool.h b/pcbnew/tools/drawing_tool.h index ff2570a936..e8041c6937 100644 --- a/pcbnew/tools/drawing_tool.h +++ b/pcbnew/tools/drawing_tool.h @@ -203,7 +203,7 @@ private: bool m_editModules; /// Stores the current line width for multisegment drawing. - unsigned int lineWidth; + unsigned int m_lineWidth; // How does line width change after one -/+ key press. static const int WIDTH_STEP = 100000; diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index fab2a18ce9..1747a8be71 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -43,7 +43,8 @@ #include "edit_tool.h" EDIT_TOOL::EDIT_TOOL() : - TOOL_INTERACTIVE( "pcbnew.InteractiveEdit" ), m_selectionTool( NULL ), m_editModules( false ) + TOOL_INTERACTIVE( "pcbnew.InteractiveEdit" ), m_selectionTool( NULL ), + m_dragging( false ), m_editModules( false ), m_updateFlag( KIGFX::VIEW_ITEM::NONE ) { } @@ -51,6 +52,7 @@ EDIT_TOOL::EDIT_TOOL() : void EDIT_TOOL::Reset( RESET_REASON aReason ) { m_dragging = false; + m_updateFlag = KIGFX::VIEW_ITEM::NONE; } diff --git a/pcbnew/tools/module_tools.cpp b/pcbnew/tools/module_tools.cpp index a020f71b36..fb05448385 100644 --- a/pcbnew/tools/module_tools.cpp +++ b/pcbnew/tools/module_tools.cpp @@ -47,7 +47,8 @@ #include MODULE_TOOLS::MODULE_TOOLS() : - TOOL_INTERACTIVE( "pcbnew.ModuleEditor" ) + TOOL_INTERACTIVE( "pcbnew.ModuleEditor" ), m_view( NULL ), m_controls( NULL ), + m_board( NULL ), m_frame( NULL ) { } diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index ef58cd3c81..cc48a28454 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -47,7 +47,7 @@ public: PCB_EDITOR_CONTROL::PCB_EDITOR_CONTROL() : - TOOL_INTERACTIVE( "pcbnew.EditorControl" ) + TOOL_INTERACTIVE( "pcbnew.EditorControl" ), m_frame( NULL ) { } diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index 8cc8e31e5b..c32c728f7f 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -41,7 +41,7 @@ PCBNEW_CONTROL::PCBNEW_CONTROL() : - TOOL_INTERACTIVE( "pcbnew.Control" ) + TOOL_INTERACTIVE( "pcbnew.Control" ), m_frame( NULL ) { } diff --git a/pcbnew/tools/placement_tool.cpp b/pcbnew/tools/placement_tool.cpp index 4e2857e866..6e647a193c 100644 --- a/pcbnew/tools/placement_tool.cpp +++ b/pcbnew/tools/placement_tool.cpp @@ -34,7 +34,7 @@ #include PLACEMENT_TOOL::PLACEMENT_TOOL() : - TOOL_INTERACTIVE( "pcbnew.Placement" ) + TOOL_INTERACTIVE( "pcbnew.Placement" ), m_selectionTool( NULL ) { }