From f4be80a3af135f1a449ee54e3764774ad19d67df Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 1 Mar 2017 09:50:36 +0100 Subject: [PATCH] Code formatting --- pcbnew/layer_widget.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/pcbnew/layer_widget.cpp b/pcbnew/layer_widget.cpp index a043930288..2fbf7be80d 100644 --- a/pcbnew/layer_widget.cpp +++ b/pcbnew/layer_widget.cpp @@ -190,8 +190,10 @@ void LAYER_WIDGET::OnTabChange( wxNotebookEvent& event ) wxWindow* LAYER_WIDGET::getLayerComp( int aRow, int aColumn ) const { unsigned ndx = aRow * LYR_COLUMN_COUNT + aColumn; + if( ndx < m_LayersFlexGridSizer->GetChildren().GetCount() ) return m_LayersFlexGridSizer->GetChildren()[ndx]->GetWindow(); + return NULL; } @@ -199,7 +201,8 @@ wxWindow* LAYER_WIDGET::getLayerComp( int aRow, int aColumn ) const int LAYER_WIDGET::findLayerRow( LAYER_NUM aLayer ) const { int count = GetLayerRowCount(); - for( int row=0; rowGetId() )) return row; } + return -1; } @@ -215,8 +219,10 @@ int LAYER_WIDGET::findLayerRow( LAYER_NUM aLayer ) const wxWindow* LAYER_WIDGET::getRenderComp( int aRow, int aColumn ) const { int ndx = aRow * RND_COLUMN_COUNT + aColumn; + if( (unsigned) ndx < m_RenderFlexGridSizer->GetChildren().GetCount() ) return m_RenderFlexGridSizer->GetChildren()[ndx]->GetWindow(); + return NULL; } @@ -224,7 +230,8 @@ wxWindow* LAYER_WIDGET::getRenderComp( int aRow, int aColumn ) const int LAYER_WIDGET::findRenderRow( int aId ) const { int count = GetRenderRowCount(); - for( int row=0; rowGetId() )) return row; } + return -1; } @@ -422,14 +430,16 @@ wxSize LAYER_WIDGET::GetBestSize() const // size of m_LayerScrolledWindow -------------- wxArrayInt widths = m_LayersFlexGridSizer->GetColWidths(); int totWidth = 0; + if( widths.GetCount() ) { - for( int i=0; iGetHGap(); // printf("widths[%d]:%d\n", i, widths[i] ); } } + // Account for the parent's frame: totWidth += 10; @@ -447,9 +457,10 @@ wxSize LAYER_WIDGET::GetBestSize() const // size of m_RenderScrolledWindow -------------- widths = m_RenderFlexGridSizer->GetColWidths(); totWidth = 0; + if( widths.GetCount() ) { - for( int i=0; iGetHGap(); // printf("widths[%d]:%d\n", i, widths[i] ); @@ -616,6 +627,7 @@ COLOR4D LAYER_WIDGET::GetLayerColor( LAYER_NUM aLayer ) const void LAYER_WIDGET::SetRenderState( int aId, bool isSet ) { int row = findRenderRow( aId ); + if( row >= 0 ) { int col = 1; // checkbox is column 1 @@ -629,6 +641,7 @@ void LAYER_WIDGET::SetRenderState( int aId, bool isSet ) bool LAYER_WIDGET::GetRenderState( int aId ) { int row = findRenderRow( aId ); + if( row >= 0 ) { int col = 1; // checkbox is column 1 @@ -636,6 +649,7 @@ bool LAYER_WIDGET::GetRenderState( int aId ) wxASSERT( cb ); return cb->GetValue(); } + return false; // the value of a non-existent row } @@ -653,6 +667,7 @@ void LAYER_WIDGET::UpdateLayouts() void LAYER_WIDGET::UpdateLayerIcons() { int rowCount = GetLayerRowCount(); + for( int row = 0; row < rowCount ; row++ ) { INDICATOR_ICON* indicator = (INDICATOR_ICON*) getLayerComp( row, COLUMN_ICON_ACTIVE );