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
This commit is contained in:
Jeff Young 2023-05-12 00:27:19 +01:00
parent 86c75cf261
commit 329025f8a7
1 changed files with 17 additions and 0 deletions

View File

@ -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 );