From bc30ee85c0240780415da1cae10e67ef2f1f2e26 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 9 Nov 2021 20:17:23 +0000 Subject: [PATCH] Make sure JSON contents are in memory before saving. Fixes https://gitlab.com/kicad/code/kicad/issues/9582 --- kicad/tools/kicad_manager_control.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kicad/tools/kicad_manager_control.cpp b/kicad/tools/kicad_manager_control.cpp index 8b6003466b..a29429bd32 100644 --- a/kicad/tools/kicad_manager_control.cpp +++ b/kicad/tools/kicad_manager_control.cpp @@ -392,11 +392,13 @@ public: else if( ext == ProjectFileExtension ) { PROJECT_FILE projectFile( aSrcFilePath ); + projectFile.LoadFromFile(); projectFile.SaveAs( destFile.GetPath(), destFile.GetName() ); } else if( ext == ProjectLocalSettingsFileExtension ) { PROJECT_LOCAL_SETTINGS projectLocalSettings( nullptr, aSrcFilePath ); + projectLocalSettings.LoadFromFile(); projectLocalSettings.SaveAs( destFile.GetPath(), destFile.GetName() ); } } @@ -540,6 +542,9 @@ int KICAD_MANAGER_CONTROL::SaveProjectAs( const TOOL_EVENT& aEvent ) wxString default_dir = m_frame->GetMruPath(); + Prj().GetProjectFile().SaveToFile(); + Prj().GetLocalSettings().SaveToFile(); + if( default_dir == currentProjectDirPath || default_dir == currentProjectDirPath + wxFileName::GetPathSeparator() ) {