mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 00:21:25 +00:00
More fixes to autosaving migrated projects
- Disable jobsets memory when opening migrated project - Add WasMigrated to project file Fixes https://gitlab.com/kicad/code/kicad/-/issues/19540
This commit is contained in:
parent
d1898aab47
commit
846f6127fd
common/project
include/project
kicad
@ -41,7 +41,8 @@ PROJECT_FILE::PROJECT_FILE( const wxString& aFullPath ) :
|
||||
m_BoardSettings(),
|
||||
m_sheets(),
|
||||
m_boards(),
|
||||
m_project( nullptr )
|
||||
m_project( nullptr ),
|
||||
m_wasMigrated( false )
|
||||
{
|
||||
// Keep old files around
|
||||
m_deleteLegacyAfterMigration = false;
|
||||
@ -162,6 +163,8 @@ bool PROJECT_FILE::migrateSchema1To2()
|
||||
for( nlohmann::json& entry : presets )
|
||||
PARAM_LAYER_PRESET::MigrateToV9Layers( entry );
|
||||
|
||||
m_wasMigrated = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -181,6 +184,8 @@ bool PROJECT_FILE::migrateSchema2To3()
|
||||
for( nlohmann::json& entry : presets )
|
||||
PARAM_LAYER_PRESET::MigrateToNamedRenderLayers( entry );
|
||||
|
||||
m_wasMigrated = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -487,6 +487,10 @@ bool PROJECT_LOCAL_SETTINGS::SaveToFile( const wxString& aDirectory, bool aForce
|
||||
Set( "meta.filename",
|
||||
m_project->GetProjectName() + "." + FILEEXT::ProjectLocalSettingsFileExtension );
|
||||
|
||||
// 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 );
|
||||
}
|
||||
|
||||
@ -496,6 +500,10 @@ bool PROJECT_LOCAL_SETTINGS::SaveAs( const wxString& aDirectory, const wxString&
|
||||
Set( "meta.filename", aFile + "." + FILEEXT::ProjectLocalSettingsFileExtension );
|
||||
SetFilename( aFile );
|
||||
|
||||
// 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, true );
|
||||
}
|
||||
|
||||
|
@ -105,6 +105,11 @@ public:
|
||||
return m_NetSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the local settings needed to be migrated, and shouldn't be auto-saved
|
||||
*/
|
||||
bool WasMigrated() const { return m_wasMigrated; }
|
||||
|
||||
protected:
|
||||
wxString getFileExt() const override;
|
||||
|
||||
@ -197,6 +202,8 @@ private:
|
||||
|
||||
/// A link to the owning PROJECT
|
||||
PROJECT* m_project;
|
||||
|
||||
bool m_wasMigrated;
|
||||
};
|
||||
|
||||
// Specializations to allow directly reading/writing FILE_INFO_PAIRs from JSON
|
||||
|
@ -82,6 +82,8 @@
|
||||
#include "kicad_manager_frame.h"
|
||||
#include "settings/kicad_settings.h"
|
||||
|
||||
#include <project/project_file.h>
|
||||
|
||||
|
||||
#define EDITORS_CAPTION _( "Editors" )
|
||||
#define PROJECT_FILES_CAPTION _( "Project Files" )
|
||||
@ -669,10 +671,13 @@ void KICAD_MANAGER_FRAME::doCloseWindow()
|
||||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::SaveOpenJobSetsToLocalSettings()
|
||||
void KICAD_MANAGER_FRAME::SaveOpenJobSetsToLocalSettings( bool aIsExplicitUserSave )
|
||||
{
|
||||
PROJECT_LOCAL_SETTINGS& cfg = Prj().GetLocalSettings();
|
||||
|
||||
if( !aIsExplicitUserSave && cfg.WasMigrated() )
|
||||
return;
|
||||
|
||||
cfg.m_OpenJobSets.clear();
|
||||
|
||||
for( size_t i = 0; i < m_notebook->GetPageCount(); i++ )
|
||||
@ -700,15 +705,21 @@ bool KICAD_MANAGER_FRAME::CloseProject( bool aSave )
|
||||
if( !Kiway().PlayersClose( false ) )
|
||||
return false;
|
||||
|
||||
bool shouldSaveProject = !Prj().GetLocalSettings().WasMigrated()
|
||||
&& !Prj().GetProjectFile().WasMigrated();
|
||||
|
||||
// Save the project file for the currently loaded project.
|
||||
if( m_active_project )
|
||||
{
|
||||
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
||||
|
||||
mgr.TriggerBackupIfNeeded( NULL_REPORTER::GetInstance() );
|
||||
if( shouldSaveProject )
|
||||
{
|
||||
mgr.TriggerBackupIfNeeded( NULL_REPORTER::GetInstance() );
|
||||
|
||||
if( aSave )
|
||||
mgr.SaveProject();
|
||||
if( aSave )
|
||||
mgr.SaveProject();
|
||||
}
|
||||
|
||||
m_active_project = false;
|
||||
mgr.UnloadProject( &Prj() );
|
||||
|
@ -171,7 +171,14 @@ public:
|
||||
|
||||
void ReCreateTreePrj();
|
||||
|
||||
void SaveOpenJobSetsToLocalSettings();
|
||||
/**
|
||||
* @param aIsExplicitUserSave is true to indicate the user ran a Save Project action explicitly
|
||||
* Note that this parameter should currently *always* be false, because there is no
|
||||
* explicit Save Project action in the project manager. This means that anytime the
|
||||
* project manager saves project local settings, it is an implicit save (and should not
|
||||
* actually save the file if it was migrated)
|
||||
*/
|
||||
void SaveOpenJobSetsToLocalSettings( bool aIsExplicitUserSave = false );
|
||||
|
||||
wxWindow* GetToolCanvas() const override;
|
||||
|
||||
|
@ -851,7 +851,8 @@ 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() )
|
||||
&& !player->GetCurrentFileName().IsEmpty()
|
||||
&& !Prj().GetLocalSettings().WasMigrated() )
|
||||
{
|
||||
wxFileName rfn( player->GetCurrentFileName() );
|
||||
rfn.MakeRelativeTo( Prj().GetProjectPath() );
|
||||
|
Loading…
Reference in New Issue
Block a user