Disable project saving outside explicit save actions

Fixes https://gitlab.com/kicad/code/kicad/-/issues/7589
This commit is contained in:
Jon Evans 2021-02-21 21:31:45 -05:00
parent a8ef81aef1
commit f1039dfb94
4 changed files with 10 additions and 10 deletions

View File

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

View File

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

View File

@ -315,13 +315,16 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& 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();

View File

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