Don't try to switch projects during autosave

Fixes https://gitlab.com/kicad/code/kicad/-/issues/4800
This commit is contained in:
Jon Evans 2020-07-05 11:02:48 -04:00
parent 1463dd10b2
commit 3ebd5b317b
2 changed files with 8 additions and 5 deletions

View File

@ -346,7 +346,7 @@ bool PCB_EDIT_FRAME::Files_io_from_id( int id )
if( id == ID_COPY_BOARD_AS )
return SavePcbCopy( filename );
else
return SavePcbFile( filename, false );
return SavePcbFile( filename, false, false );
}
return false;
}
@ -674,7 +674,8 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
}
bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool addToHistory )
bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool addToHistory,
bool aChangeProject )
{
// please, keep it simple. prompting goes elsewhere.
@ -697,7 +698,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool addToHistory )
wxFileName projectFile( pcbFileName );
projectFile.SetExt( ProjectFileExtension );
if( !projectFile.FileExists() )
if( aChangeProject && !projectFile.FileExists() )
{
// If this is a new board, project filename won't be set yet
if( projectFile.GetFullPath() != Prj().GetProjectFullName() )
@ -886,7 +887,7 @@ bool PCB_EDIT_FRAME::doAutoSave()
wxLogTrace( traceAutoSave, "Creating auto save file <" + autoSaveFileName.GetFullPath() + ">" );
if( SavePcbFile( autoSaveFileName.GetFullPath(), false ) )
if( SavePcbFile( autoSaveFileName.GetFullPath(), false, false ) )
{
GetScreen()->SetModify();
GetBoard()->SetFileName( tmpFileName.GetFullPath() );

View File

@ -603,9 +603,11 @@ public:
* @param aFileName The file name to write or wxEmptyString to prompt user for
* file name.
* @param addToHistory controsl whether or not to add the saved file to the recent file list
* @param aChangeProject is true if the project should be changed to the new board filename
* @return True if file was saved successfully.
*/
bool SavePcbFile( const wxString& aFileName, bool addToHistory = true );
bool SavePcbFile( const wxString& aFileName, bool addToHistory = true,
bool aChangeProject = true );
/**
* Function SavePcbCopy