From 329025f8a7e9f2a7f1a55f180fef2fa7ec001c90 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 12 May 2023 00:27:19 +0100 Subject: [PATCH] Update "simple" MRU paths in project Save As. Update only those that are the project name + extension. Fixes https://gitlab.com/kicad/code/kicad/issues/14681 --- common/project/project_file.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/common/project/project_file.cpp b/common/project/project_file.cpp index 13a2fe0797..2a79ddf388 100644 --- a/common/project/project_file.cpp +++ b/common/project/project_file.cpp @@ -569,9 +569,26 @@ bool PROJECT_FILE::SaveToFile( const wxString& aDirectory, bool aForce ) bool PROJECT_FILE::SaveAs( const wxString& aDirectory, const wxString& aFile ) { + wxFileName oldFilename( GetFilename() ); + wxString oldProjectName = oldFilename.GetName(); + Set( "meta.filename", aFile + "." + ProjectFileExtension ); SetFilename( aFile ); + auto updatePath = + [&]( wxString& aPath ) + { + if( aPath.StartsWith( oldProjectName + wxS( "." ) ) ) + aPath.Replace( oldProjectName, aFile, false ); + }; + + updatePath( m_PcbLastPath[ LAST_PATH_NETLIST ] ); + updatePath( m_PcbLastPath[ LAST_PATH_STEP ] ); + updatePath( m_PcbLastPath[ LAST_PATH_IDF ] ); + updatePath( m_PcbLastPath[ LAST_PATH_VRML ] ); + updatePath( m_PcbLastPath[ LAST_PATH_SPECCTRADSN ] ); + updatePath( m_PcbLastPath[ LAST_PATH_GENCAD ] ); + // While performing Save As, we have already checked that we can write to the directory // so don't carry the previous flag SetReadOnly( false );