From f1039dfb9443425ab31fa566ad1cddb87fc58ddf Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 21 Feb 2021 21:31:45 -0500 Subject: [PATCH] Disable project saving outside explicit save actions Fixes https://gitlab.com/kicad/code/kicad/-/issues/7589 --- common/settings/json_settings.cpp | 3 ++- common/settings/settings_manager.cpp | 2 +- eeschema/files-io.cpp | 12 ++++++------ eeschema/sch_edit_frame.cpp | 3 +-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/common/settings/json_settings.cpp b/common/settings/json_settings.cpp index 406b4bd37f..435915fcc7 100644 --- a/common/settings/json_settings.cpp +++ b/common/settings/json_settings.cpp @@ -292,7 +292,8 @@ bool JSON_SETTINGS::LoadFromFile( const wxString& aDirectory ) } // And write-out immediately so that we don't lose data if the program later crashes. - SaveToFile( aDirectory, true ); + if( m_deleteLegacyAfterMigration ) + SaveToFile( aDirectory, true ); } return success; diff --git a/common/settings/settings_manager.cpp b/common/settings/settings_manager.cpp index d4966758cb..dd280127e7 100644 --- a/common/settings/settings_manager.cpp +++ b/common/settings/settings_manager.cpp @@ -750,7 +750,7 @@ bool SETTINGS_MANAGER::LoadProject( const wxString& aFullPath, bool aSetActive ) if( aSetActive && !m_projects.empty() ) { PROJECT* oldProject = m_projects.begin()->second; - unloadProjectFile( oldProject, true ); + unloadProjectFile( oldProject, false ); m_projects.erase( m_projects.begin() ); } diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 73c4983414..ad4e67f250 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -315,13 +315,16 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in GetSettingsManager()->SaveProject(); Schematic().SetProject( nullptr ); - GetSettingsManager()->UnloadProject( &Prj() ); + GetSettingsManager()->UnloadProject( &Prj(), false ); GetSettingsManager()->LoadProject( pro.GetFullPath() ); + wxFileName legacyPro( pro ); + legacyPro.SetExt( LegacyProjectFileExtension ); + // Do not allow saving a project if one doesn't exist. This normally happens if we are // standalone and opening a schematic that has been moved from its project folder. - if( !pro.Exists() && !( aCtl & KICTL_CREATE ) ) + if( !pro.Exists() && !legacyPro.Exists() && !( aCtl & KICTL_CREATE ) ) Prj().SetReadOnly(); CreateScreens(); @@ -667,11 +670,8 @@ void SCH_EDIT_FRAME::OnImportProject( wxCommandEvent& aEvent ) if( setProject ) { - if( !Prj().IsNullProject() ) - GetSettingsManager()->SaveProject(); - Schematic().SetProject( nullptr ); - GetSettingsManager()->UnloadProject( &Prj() ); + GetSettingsManager()->UnloadProject( &Prj(), false ); Schematic().Reset(); diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 41c22621d9..b63a13e0f3 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -322,7 +322,7 @@ SCH_EDIT_FRAME::~SCH_EDIT_FRAME() // Close the project if we are standalone, so it gets cleaned up properly if( Kiface().IsSingle() ) - GetSettingsManager()->UnloadProject( &Prj() ); + GetSettingsManager()->UnloadProject( &Prj(), false ); } @@ -704,7 +704,6 @@ void SCH_EDIT_FRAME::doCloseWindow() // Clear view before destroying schematic as repaints depend on schematic being valid SetScreen( nullptr ); - GetSettingsManager()->SaveProject(); Schematic().Reset(); Destroy();