mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-04 22:55:30 +00:00
Don't autosave future formats of project settings
Fixes https://gitlab.com/kicad/code/kicad/-/issues/19910
This commit is contained in:
parent
458df1ebab
commit
7d689e0c61
common
include
kicad
pcbnew
@ -589,6 +589,10 @@ bool PROJECT_FILE::SaveToFile( const wxString& aDirectory, bool aForce )
|
||||
|
||||
Set( "meta.filename", m_project->GetProjectName() + "." + FILEEXT::ProjectFileExtension );
|
||||
|
||||
// If we're actually going ahead and doing the save, the flag that keeps code from doing the save
|
||||
// should be cleared at this point
|
||||
m_wasMigrated = false;
|
||||
|
||||
return JSON_SETTINGS::SaveToFile( aDirectory, aForce );
|
||||
}
|
||||
|
||||
@ -631,6 +635,10 @@ bool PROJECT_FILE::SaveAs( const wxString& aDirectory, const wxString& aFile )
|
||||
updatePathByPtr( "schematic.ngspice.workbook_filename" );
|
||||
updatePathByPtr( "pcbnew.page_layout_descr_file" );
|
||||
|
||||
// If we're actually going ahead and doing the save, the flag that keeps code from doing the save
|
||||
// should be cleared at this point
|
||||
m_wasMigrated = false;
|
||||
|
||||
// While performing Save As, we have already checked that we can write to the directory
|
||||
// so don't carry the previous flag
|
||||
SetReadOnly( false );
|
||||
|
@ -79,6 +79,7 @@ JSON_SETTINGS::JSON_SETTINGS( const wxString& aFilename, SETTINGS_LOC aLocation,
|
||||
m_deleteLegacyAfterMigration( true ),
|
||||
m_resetParamsIfMissing( true ),
|
||||
m_schemaVersion( aSchemaVersion ),
|
||||
m_isFutureFormat( false ),
|
||||
m_manager( nullptr )
|
||||
{
|
||||
m_internals = std::make_unique<JSON_SETTINGS_INTERNALS>();
|
||||
@ -325,6 +326,7 @@ bool JSON_SETTINGS::LoadFromFile( const wxString& aDirectory )
|
||||
wxLogTrace( traceSettings,
|
||||
wxT( "%s: warning: file version %d is newer than latest (%d)" ),
|
||||
GetFullFilename(), filever, m_schemaVersion );
|
||||
m_isFutureFormat = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1185,7 +1185,7 @@ bool SETTINGS_MANAGER::unloadProjectFile( PROJECT* aProject, bool aSave )
|
||||
|
||||
PROJECT_FILE* file = m_project_files[name];
|
||||
|
||||
if( file->WasMigrated() )
|
||||
if( !file->ShouldAutoSave() )
|
||||
aSave = false;
|
||||
|
||||
auto it = std::find_if( m_settings.begin(), m_settings.end(),
|
||||
@ -1198,7 +1198,7 @@ bool SETTINGS_MANAGER::unloadProjectFile( PROJECT* aProject, bool aSave )
|
||||
{
|
||||
wxString projectPath = GetPathForSettingsFile( it->get() );
|
||||
|
||||
bool saveLocalSettings = aSave && !aProject->GetLocalSettings().WasMigrated();
|
||||
bool saveLocalSettings = aSave && aProject->GetLocalSettings().ShouldAutoSave();
|
||||
|
||||
FlushAndRelease( &aProject->GetLocalSettings(), saveLocalSettings );
|
||||
|
||||
|
@ -104,9 +104,9 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the local settings needed to be migrated, and shouldn't be auto-saved
|
||||
* @return true if it should be safe to auto-save this file without user action
|
||||
*/
|
||||
bool WasMigrated() const { return m_wasMigrated; }
|
||||
bool ShouldAutoSave() const { return !m_wasMigrated && !m_isFutureFormat; }
|
||||
|
||||
protected:
|
||||
wxString getFileExt() const override;
|
||||
|
@ -72,9 +72,9 @@ public:
|
||||
void ClearFileState();
|
||||
|
||||
/**
|
||||
* @return true if the local settings needed to be migrated, and shouldn't be auto-saved
|
||||
* @return true if it should be safe to auto-save this file without user action
|
||||
*/
|
||||
bool WasMigrated() const { return m_wasMigrated; }
|
||||
bool ShouldAutoSave() const { return !m_wasMigrated && !m_isFutureFormat; }
|
||||
|
||||
protected:
|
||||
wxString getFileExt() const override
|
||||
|
@ -332,6 +332,9 @@ protected:
|
||||
/// Version of this settings schema.
|
||||
int m_schemaVersion;
|
||||
|
||||
/// Set to true if this settings is loaded from a file with a newer schema version than is known
|
||||
bool m_isFutureFormat;
|
||||
|
||||
/// A pointer to the settings manager managing this file (may be null)
|
||||
SETTINGS_MANAGER* m_manager;
|
||||
|
||||
|
@ -602,8 +602,8 @@ bool KICAD_MANAGER_FRAME::CloseProject( bool aSave )
|
||||
if( !Kiway().PlayersClose( false ) )
|
||||
return false;
|
||||
|
||||
bool shouldSaveProject = !Prj().GetLocalSettings().WasMigrated()
|
||||
&& !Prj().GetProjectFile().WasMigrated();
|
||||
bool shouldSaveProject = Prj().GetLocalSettings().ShouldAutoSave()
|
||||
&& Prj().GetProjectFile().ShouldAutoSave();
|
||||
|
||||
// Save the project file for the currently loaded project.
|
||||
if( m_active_project )
|
||||
|
@ -809,7 +809,7 @@ int KICAD_MANAGER_CONTROL::ShowPlayer( const TOOL_EVENT& aEvent )
|
||||
// Save window state to disk now. Don't wait around for a crash.
|
||||
if( Pgm().GetCommonSettings()->m_Session.remember_open_files
|
||||
&& !player->GetCurrentFileName().IsEmpty()
|
||||
&& !Prj().GetLocalSettings().WasMigrated() )
|
||||
&& Prj().GetLocalSettings().ShouldAutoSave() )
|
||||
{
|
||||
wxFileName rfn( player->GetCurrentFileName() );
|
||||
rfn.MakeRelativeTo( Prj().GetProjectPath() );
|
||||
|
@ -1168,7 +1168,7 @@ void PCB_EDIT_FRAME::doCloseWindow()
|
||||
}
|
||||
|
||||
// Make sure local settings are persisted
|
||||
if( !Prj().GetLocalSettings().WasMigrated() )
|
||||
if( Prj().GetLocalSettings().ShouldAutoSave() )
|
||||
SaveProjectLocalSettings();
|
||||
else
|
||||
wxLogTrace( traceAutoSave, wxT( "Skipping auto-save of migrated local settings" ) );
|
||||
|
Loading…
Reference in New Issue
Block a user