Don't try to save hierarchical sheets with empty filenames
Fixes https://gitlab.com/kicad/code/kicad/-/issues/11236
This commit is contained in:
parent
ee0a41e3bc
commit
314c813aca
|
@ -674,6 +674,9 @@ bool SCH_EDIT_FRAME::saveSchematicFile( SCH_SHEET* aSheet, const wxString& aSave
|
||||||
|
|
||||||
wxCHECK( screen, false );
|
wxCHECK( screen, false );
|
||||||
|
|
||||||
|
// Cannot save to nowhere
|
||||||
|
wxCHECK( !aSavePath.IsEmpty(), false );
|
||||||
|
|
||||||
// Construct the name of the file to be saved
|
// Construct the name of the file to be saved
|
||||||
schematicFileName = Prj().AbsolutePath( aSavePath );
|
schematicFileName = Prj().AbsolutePath( aSavePath );
|
||||||
oldFileName = schematicFileName;
|
oldFileName = schematicFileName;
|
||||||
|
@ -771,10 +774,10 @@ bool SCH_EDIT_FRAME::SaveProject( bool aSaveAs )
|
||||||
wxString msg;
|
wxString msg;
|
||||||
SCH_SCREEN* screen;
|
SCH_SCREEN* screen;
|
||||||
SCH_SCREENS screens( Schematic().Root() );
|
SCH_SCREENS screens( Schematic().Root() );
|
||||||
bool saveCopy = aSaveAs && !Kiface().IsSingle();
|
bool saveCopy = aSaveAs && !Kiface().IsSingle();
|
||||||
bool success = true;
|
bool success = true;
|
||||||
bool updateFileType = false;
|
bool updateFileHistory = false;
|
||||||
bool createNewProject = false;
|
bool createNewProject = false;
|
||||||
|
|
||||||
// I want to see it in the debugger, show me the string! Can't do that with wxFileName.
|
// I want to see it in the debugger, show me the string! Can't do that with wxFileName.
|
||||||
wxString fileName = Prj().AbsolutePath( Schematic().Root().GetFileName() );
|
wxString fileName = Prj().AbsolutePath( Schematic().Root().GetFileName() );
|
||||||
|
@ -856,6 +859,7 @@ bool SCH_EDIT_FRAME::SaveProject( bool aSaveAs )
|
||||||
{
|
{
|
||||||
Schematic().Root().SetFileName( newFileName.GetFullName() );
|
Schematic().Root().SetFileName( newFileName.GetFullName() );
|
||||||
Schematic().RootScreen()->SetFileName( newFileName.GetFullPath() );
|
Schematic().RootScreen()->SetFileName( newFileName.GetFullPath() );
|
||||||
|
updateFileHistory = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -933,6 +937,11 @@ bool SCH_EDIT_FRAME::SaveProject( bool aSaveAs )
|
||||||
sheet.MakeFilePathRelativeToParentSheet();
|
sheet.MakeFilePathRelativeToParentSheet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if( !fn.FileExists() )
|
||||||
|
{
|
||||||
|
// File doesn't exist yet; true if we just imported something
|
||||||
|
updateFileHistory = true;
|
||||||
|
}
|
||||||
|
|
||||||
if( filenameMap.empty() || !saveCopy )
|
if( filenameMap.empty() || !saveCopy )
|
||||||
{
|
{
|
||||||
|
@ -999,7 +1008,7 @@ bool SCH_EDIT_FRAME::SaveProject( bool aSaveAs )
|
||||||
|
|
||||||
if( tmpFn.IsOk() && tmpFn.GetExt() != KiCadSchematicFileExtension )
|
if( tmpFn.IsOk() && tmpFn.GetExt() != KiCadSchematicFileExtension )
|
||||||
{
|
{
|
||||||
updateFileType = true;
|
updateFileHistory = true;
|
||||||
tmpFn.SetExt( KiCadSchematicFileExtension );
|
tmpFn.SetExt( KiCadSchematicFileExtension );
|
||||||
|
|
||||||
for( EDA_ITEM* item : screen->Items().OfType( SCH_SHEET_T ) )
|
for( EDA_ITEM* item : screen->Items().OfType( SCH_SHEET_T ) )
|
||||||
|
@ -1021,6 +1030,10 @@ bool SCH_EDIT_FRAME::SaveProject( bool aSaveAs )
|
||||||
screen->SetFileName( tmpFn.GetFullPath() );
|
screen->SetFileName( tmpFn.GetFullPath() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do not save sheet symbols with no valid filename set
|
||||||
|
if( !tmpFn.IsOk() )
|
||||||
|
continue;
|
||||||
|
|
||||||
std::vector<SCH_SHEET_PATH>& sheets = screen->GetClientSheetPaths();
|
std::vector<SCH_SHEET_PATH>& sheets = screen->GetClientSheetPaths();
|
||||||
|
|
||||||
if( sheets.size() == 1 )
|
if( sheets.size() == 1 )
|
||||||
|
@ -1045,7 +1058,7 @@ bool SCH_EDIT_FRAME::SaveProject( bool aSaveAs )
|
||||||
if( aSaveAs && success )
|
if( aSaveAs && success )
|
||||||
LockFile( Schematic().RootScreen()->GetFileName() );
|
LockFile( Schematic().RootScreen()->GetFileName() );
|
||||||
|
|
||||||
if( updateFileType )
|
if( updateFileHistory )
|
||||||
UpdateFileHistory( Schematic().RootScreen()->GetFileName() );
|
UpdateFileHistory( Schematic().RootScreen()->GetFileName() );
|
||||||
|
|
||||||
// Save the sheet name map to the project file
|
// Save the sheet name map to the project file
|
||||||
|
|
Loading…
Reference in New Issue