From fd0a89c23fe58e4c1db7d8190055450f1059dd53 Mon Sep 17 00:00:00 2001 From: g_harland Date: Thu, 22 Nov 2007 00:40:17 +0000 Subject: [PATCH] Fix bug in GerbView's Export to Pcbnew command --- gerbview/export_to_pcbnew.cpp | 10 +++++----- gerbview/select_layers_to_pcb.cpp | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp index bde5aa3c06..3fcb17d0d3 100644 --- a/gerbview/export_to_pcbnew.cpp +++ b/gerbview/export_to_pcbnew.cpp @@ -29,10 +29,10 @@ void WinEDA_GerberFrame::ExportDataInPcbnewFormat( wxCommandEvent& event ) bool no_used_layers = true; // Changed to false if any used layer found // Check whether any of the Gerber layers are actually currently used - while( no_used_layers && ii < 32 ) - { - if( g_GERBER_Descr_List[ii] != NULL ) - no_used_layers = false; + while( no_used_layers && ii < 32 ) + { + if( g_GERBER_Descr_List[ii] != NULL ) + no_used_layers = false; ii++; } @@ -150,7 +150,7 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile, { int layer = track->GetLayer(); int pcb_layer_number = LayerLookUpTable[layer]; - if( pcb_layer_number < 0 ) + if( pcb_layer_number < 0 || pcb_layer_number > LAST_NO_COPPER_LAYER ) continue; if( pcb_layer_number > LAST_COPPER_LAYER ) diff --git a/gerbview/select_layers_to_pcb.cpp b/gerbview/select_layers_to_pcb.cpp index d9b012a22d..0344b9f7da 100644 --- a/gerbview/select_layers_to_pcb.cpp +++ b/gerbview/select_layers_to_pcb.cpp @@ -13,6 +13,7 @@ #include "wx/statline.h" /* Variables locales */ +#define LAYER_UNSELECTED NB_LAYERS static int ButtonTable[32]; // Indexes buttons to Gerber layers static int LayerLookUpTable[32]; // Indexes Gerber layers to PCB file layers wxStaticText* layer_list[32]; // Indexes text strings to buttons @@ -57,7 +58,7 @@ private: /* Table des evenements pour WinEDA_SwapLayerFrame */ BEGIN_EVENT_TABLE(WinEDA_SwapLayerFrame, wxDialog) - EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + NB_LAYERS - 1, + EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + 31, wxEVT_COMMAND_BUTTON_CLICKED, WinEDA_SwapLayerFrame::Sel_Layer ) EVT_BUTTON( wxID_OK, WinEDA_SwapLayerFrame::OnOkClick ) @@ -131,7 +132,7 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame(WinEDA_GerberFrame *parent) : // Specify the default value for each member of these arrays. ButtonTable[ii] = -1; - LayerLookUpTable[ii] = NB_LAYERS; // Value associated with deselected Gerber layer + LayerLookUpTable[ii] = LAYER_UNSELECTED; // Value associated with deselected Gerber layer } int pcb_layer_number = 0; @@ -312,17 +313,17 @@ void WinEDA_SwapLayerFrame::Sel_Layer(wxCommandEvent& event) ii = event.GetId() - ID_BUTTON_0; jj = LayerLookUpTable[ButtonTable[ii]]; - if( (jj < 0) || (jj > NB_LAYERS) ) + if( (jj < 0) || (jj > LAYER_UNSELECTED) ) jj = 0; // (Defaults to "Copper" layer.) jj = m_Parent->SelectLayer(jj, -1, -1, true); - if( (jj < 0) || (jj > NB_LAYERS) ) + if( (jj < 0) || (jj > LAYER_UNSELECTED) ) return; if( jj != LayerLookUpTable[ButtonTable[ii]] ) { LayerLookUpTable[ButtonTable[ii]] = jj; - if( jj == NB_LAYERS ) + if( jj == LAYER_UNSELECTED ) { layer_list[ii]->SetLabel( _( "Do not export" ) ); // Change the text color to blue (to highlight