Pcbnew: fix a crash when trying to export a footprint in a non writable directory, or if a non writable old file was existing. (Linux only. On Windows, the wxWidgets file dialog dectects this issue)

This commit is contained in:
jean-pierre charras 2016-02-23 09:16:50 -05:00 committed by Wayne Stambaugh
parent ab0e3d0ce2
commit 34217c0199
1 changed files with 9 additions and 0 deletions

View File

@ -344,6 +344,15 @@ void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule )
pcb_io.Format( aModule );
FILE* fp = wxFopen( dlg.GetPath(), wxT( "wt" ) );
if( fp == NULL )
{
wxMessageBox( wxString::Format(
_( "Unable to create or write file '%s'" ),
GetChars( dlg.GetPath() ) ) );
return;
}
fprintf( fp, "%s", pcb_io.GetStringOutput( false ).c_str() );
fclose( fp );
}