From 3ebd5b317b5c38ad31c846f12fe4bd1f84c58efc Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 5 Jul 2020 11:02:48 -0400 Subject: [PATCH] Don't try to switch projects during autosave Fixes https://gitlab.com/kicad/code/kicad/-/issues/4800 --- pcbnew/files.cpp | 9 +++++---- pcbnew/pcb_edit_frame.h | 4 +++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index d0b7c6baaa..de8b0535ab 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -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& 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() ); diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index ee26742fc7..71ee492759 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -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