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

(Cherry-picked from 88e0ef548d)
This commit is contained in:
Ian McInerney 2020-01-26 15:43:19 +00:00
parent 798e4c288a
commit 1cbee4c504
1 changed files with 9 additions and 5 deletions

View File

@ -185,17 +185,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
@ -207,9 +207,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() );
}