From 88e0ef548d00f6cf0131481e7dc964aeb3f33bd1 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Sun, 26 Jan 2020 15:43:19 +0000 Subject: [PATCH] gerbview: Add default filename to export to pcbnew function Some platforms (such as Linux) don't automatically append file extensions, so we should ensure extensions are correct and the user is prompted accordingly. Fixes https://gitlab.com/kicad/code/kicad/issues/3817 --- gerbview/export_to_pcbnew.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp index 3dfb432742..6592425f5f 100644 --- a/gerbview/export_to_pcbnew.cpp +++ b/gerbview/export_to_pcbnew.cpp @@ -193,17 +193,17 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event ) return; } - wxString fileName; + wxString fileDialogName( wxT( "noname." ) + KiCadPcbFileExtension ); wxString path = m_mruPath; wxFileDialog filedlg( this, _( "Board File Name" ), - path, fileName, PcbFileWildcard(), + path, fileDialogName, PcbFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); if( filedlg.ShowModal() == wxID_CANCEL ) return; - fileName = filedlg.GetPath(); + wxFileName fileName = filedlg.GetPath(); /* Install a dialog frame to choose the mapping * between gerber layers and Pcbnew layers @@ -215,9 +215,13 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event ) if( ok != wxID_OK ) return; - m_mruPath = wxFileName( fileName ).GetPath(); + // If no extension was entered, then force the extension to be a KiCad PCB file + if( !fileName.HasExt() ) + fileName.SetExt( KiCadPcbFileExtension ); - GBR_TO_PCB_EXPORTER gbr_exporter( this, fileName ); + m_mruPath = fileName.GetPath(); + + GBR_TO_PCB_EXPORTER gbr_exporter( this, fileName.GetFullPath() ); gbr_exporter.ExportPcb( layerdlg->GetLayersLookUpTable(), layerdlg->GetCopperLayersCount() ); }