From 680ca22279804d0b1c53faec47601050def3bf79 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 20 Jul 2014 19:41:12 +0200 Subject: [PATCH] Fix crash in Pcbnew and Gerbview when seceting (in layers manager) "always hide all layers but activer" --- gerbview/class_gerbview_layer_widget.cpp | 4 ++-- pcbnew/class_pcb_layer_widget.cpp | 6 +++--- pcbnew/layer_widget.h | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gerbview/class_gerbview_layer_widget.cpp b/gerbview/class_gerbview_layer_widget.cpp index 6101db824d..3cccd72f37 100644 --- a/gerbview/class_gerbview_layer_widget.cpp +++ b/gerbview/class_gerbview_layer_widget.cpp @@ -186,7 +186,7 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event ) rowCount = GetLayerRowCount(); for( int row=0; row < rowCount; ++row ) { - wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, 3 ); + wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB ); int layer = getDecodedId( cb->GetId() ); bool loc_visible = visible; @@ -317,7 +317,7 @@ void GERBER_LAYER_WIDGET::UpdateLayerIcons() int row_count = GetLayerRowCount(); for( int row = 0; row < row_count ; row++ ) { - wxStaticBitmap* bm = (wxStaticBitmap*) getLayerComp( row, 0 ); + wxStaticBitmap* bm = (wxStaticBitmap*) getLayerComp( row, COLUMN_ICON_ACTIVE ); if( bm == NULL) continue; diff --git a/pcbnew/class_pcb_layer_widget.cpp b/pcbnew/class_pcb_layer_widget.cpp index 04954b1248..e975ea3430 100644 --- a/pcbnew/class_pcb_layer_widget.cpp +++ b/pcbnew/class_pcb_layer_widget.cpp @@ -167,7 +167,7 @@ void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event ) rowCount = GetLayerRowCount(); for( int row = rowCount-1; row>=0; --row ) { - wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, 3 ); + wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB ); LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) ); if( IsCopperLayer( layer ) ) @@ -180,7 +180,7 @@ void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event ) // Enable/disable the copper layers visibility: for( int row=0; rowGetId() ) ); if( IsCopperLayer( layer ) ) @@ -264,7 +264,7 @@ void PCB_LAYER_WIDGET::SyncLayerVisibilities() // this utilizes more implementation knowledge than ideal, eventually // add member ROW getRow() or similar to base LAYER_WIDGET. - wxWindow* w = getLayerComp( row, 0 ); + wxWindow* w = getLayerComp( row, COLUMN_ICON_ACTIVE ); LAYER_ID layerId = ToLAYER_ID( getDecodedId( w->GetId() ) ); diff --git a/pcbnew/layer_widget.h b/pcbnew/layer_widget.h index e788cc4608..a5dd8490b6 100644 --- a/pcbnew/layer_widget.h +++ b/pcbnew/layer_widget.h @@ -47,6 +47,7 @@ #define LYR_COLUMN_COUNT 4 ///< Layer tab column count #define RND_COLUMN_COUNT 2 ///< Rendering tab column count +#define COLUMN_ICON_ACTIVE 0 #define COLUMN_COLORBM 1 #define COLUMN_COLOR_LYR_CB 2 #define COLUMN_COLOR_LYRNAME 3