Gerbview: Keep existing layer selected if user clicks Cancel on 'Select Layer' dialog

Fixes https://gitlab.com/kicad/code/kicad/-/issues/4752
This commit is contained in:
Peter Montgomery 2020-07-11 09:40:46 +00:00 committed by Ian McInerney
parent a1a8eca844
commit 73168a9405
1 changed files with 7 additions and 3 deletions

View File

@ -49,6 +49,7 @@ enum layer_sel_id {
class SELECT_LAYER_DIALOG : public DIALOG_SHIM class SELECT_LAYER_DIALOG : public DIALOG_SHIM
{ {
private: private:
int m_PassedDefaultLayer; // Remember this in case user hits Cancel
wxRadioBox* m_layerRadioBox; wxRadioBox* m_layerRadioBox;
std::vector <int> m_layerId; std::vector <int> m_layerId;
@ -113,6 +114,9 @@ SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent, int aDefaultLa
wxArrayString layerList; wxArrayString layerList;
int selected = -1; 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 // Build the layer list; first build copper layers list
int layerCount = 0; int layerCount = 0;
@ -203,7 +207,7 @@ void SELECT_LAYER_DIALOG::OnLayerSelected( wxCommandEvent& event )
void SELECT_LAYER_DIALOG::OnCancelClick( wxCommandEvent& event ) void SELECT_LAYER_DIALOG::OnCancelClick( wxCommandEvent& event )
{ {
EndModal( -1 ); EndModal( m_PassedDefaultLayer );
} }
// This function is a duplicate of // This function is a duplicate of
@ -266,7 +270,7 @@ const wxString GetPCBDefaultLayerName( int aLayerId )
case Eco2_User: txt = wxT( "Eco2.User" ); break; case Eco2_User: txt = wxT( "Eco2.User" ); break;
case Edge_Cuts: txt = wxT( "Edge.Cuts" ); 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 default: // Sentinel
txt = wxT( "" ); break; txt = wxT( "" ); break;