From 73168a9405aba991fa74b84c7b00fa63d498a340 Mon Sep 17 00:00:00 2001 From: Peter Montgomery Date: Sat, 11 Jul 2020 09:40:46 +0000 Subject: [PATCH] Gerbview: Keep existing layer selected if user clicks Cancel on 'Select Layer' dialog Fixes https://gitlab.com/kicad/code/kicad/-/issues/4752 --- gerbview/dialogs/dialog_select_one_pcb_layer.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gerbview/dialogs/dialog_select_one_pcb_layer.cpp b/gerbview/dialogs/dialog_select_one_pcb_layer.cpp index c2900f89b6..4c43437272 100644 --- a/gerbview/dialogs/dialog_select_one_pcb_layer.cpp +++ b/gerbview/dialogs/dialog_select_one_pcb_layer.cpp @@ -49,7 +49,8 @@ enum layer_sel_id { class SELECT_LAYER_DIALOG : public DIALOG_SHIM { private: - wxRadioBox* m_layerRadioBox; + int m_PassedDefaultLayer; // Remember this in case user hits Cancel + wxRadioBox* m_layerRadioBox; std::vector m_layerId; public: @@ -113,6 +114,9 @@ SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent, int aDefaultLa wxArrayString layerList; int selected = -1; + // Store the passed default layer in case the user hits Cancel + m_PassedDefaultLayer = aDefaultLayer; + // Build the layer list; first build copper layers list int layerCount = 0; @@ -203,7 +207,7 @@ void SELECT_LAYER_DIALOG::OnLayerSelected( wxCommandEvent& event ) void SELECT_LAYER_DIALOG::OnCancelClick( wxCommandEvent& event ) { - EndModal( -1 ); + EndModal( m_PassedDefaultLayer ); } // This function is a duplicate of @@ -266,7 +270,7 @@ const wxString GetPCBDefaultLayerName( int aLayerId ) case Eco2_User: txt = wxT( "Eco2.User" ); break; case Edge_Cuts: txt = wxT( "Edge.Cuts" ); break; - // Pcbnew konws some oter layers. But any other layer is not suitable for export. + // Pcbnew knows some other layers, but any other layer is not suitable for export. default: // Sentinel txt = wxT( "" ); break;