Eeschema: fix save-as dispatching from new file

Fixes https://gitlab.com/kicad/code/kicad/-/issues/5937
This commit is contained in:
Jon Evans 2020-10-12 19:41:38 -04:00
parent 2e6968e7eb
commit 7b5d628e4b
1 changed files with 6 additions and 3 deletions

View File

@ -698,7 +698,7 @@ bool SCH_EDIT_FRAME::SaveProject()
wxString fileName = Prj().AbsolutePath( Schematic().Root().GetFileName() );
wxFileName fn = fileName;
if( !fn.IsDirWritable() )
if( fn.IsOk() && !fn.IsDirWritable() )
{
msg = wxString::Format( _( "Directory \"%s\" is not writable." ), fn.GetPath() );
DisplayError( this, msg );
@ -717,6 +717,9 @@ bool SCH_EDIT_FRAME::SaveProject()
// Convert legacy schematics file name extensions for the new format.
wxFileName tmpFn = screen->GetFileName();
if( !tmpFn.IsOk() )
continue;
if( tmpFn.GetExt() == KiCadSchematicFileExtension )
continue;
@ -761,7 +764,7 @@ bool SCH_EDIT_FRAME::SaveProject()
// Convert legacy schematics file name extensions for the new format.
wxFileName tmpFn = screen->GetFileName();
if( tmpFn.GetExt() != KiCadSchematicFileExtension )
if( tmpFn.IsOk() && tmpFn.GetExt() != KiCadSchematicFileExtension )
{
updateFileType = true;
tmpFn.SetExt( KiCadSchematicFileExtension );
@ -771,7 +774,7 @@ bool SCH_EDIT_FRAME::SaveProject()
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
wxFileName sheetFileName = sheet->GetFileName();
if( sheetFileName.GetExt() == KiCadSchematicFileExtension )
if( !sheetFileName.IsOk() || sheetFileName.GetExt() == KiCadSchematicFileExtension )
continue;
sheetFileName.SetExt( KiCadSchematicFileExtension );