Don't nag when we can't save project settings
Fixes https://gitlab.com/kicad/code/kicad/-/issues/4164
This commit is contained in:
parent
5444a1b4b0
commit
5401f06fce
|
@ -105,16 +105,20 @@ bool JSON_SETTINGS::LoadFromFile( const std::string& aDirectory )
|
||||||
|
|
||||||
auto migrateFromLegacy = [&] ( wxFileName& aPath ) {
|
auto migrateFromLegacy = [&] ( wxFileName& aPath ) {
|
||||||
// Backup and restore during migration so that the original can be mutated if convenient
|
// Backup and restore during migration so that the original can be mutated if convenient
|
||||||
|
bool backed_up = false;
|
||||||
wxFileName temp;
|
wxFileName temp;
|
||||||
temp.AssignTempFileName( aPath.GetFullPath() );
|
|
||||||
|
|
||||||
bool backed_up = true;
|
if( aPath.IsDirWritable() )
|
||||||
|
|
||||||
if( !wxCopyFile( aPath.GetFullPath(), temp.GetFullPath() ) )
|
|
||||||
{
|
{
|
||||||
wxLogTrace( traceSettings, "%s: could not create temp file for migration",
|
temp.AssignTempFileName( aPath.GetFullPath() );
|
||||||
|
|
||||||
|
if( !wxCopyFile( aPath.GetFullPath(), temp.GetFullPath() ) )
|
||||||
|
{
|
||||||
|
wxLogTrace( traceSettings, "%s: could not create temp file for migration",
|
||||||
GetFullFilename() );
|
GetFullFilename() );
|
||||||
backed_up = false;
|
}
|
||||||
|
else
|
||||||
|
backed_up = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxConfigBase::DontCreateOnDemand();
|
wxConfigBase::DontCreateOnDemand();
|
||||||
|
@ -307,6 +311,12 @@ bool JSON_SETTINGS::SaveToFile( const std::string& aDirectory, bool aForce )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( !path.IsFileWritable() )
|
||||||
|
{
|
||||||
|
wxLogTrace( traceSettings, "File for %s is read-only; not saving", GetFullFilename() );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool modified = false;
|
bool modified = false;
|
||||||
|
|
||||||
for( auto settings : m_nested_settings )
|
for( auto settings : m_nested_settings )
|
||||||
|
|
|
@ -137,7 +137,7 @@ void PCB_EDIT_FRAME::SaveProjectSettings()
|
||||||
if( !fn.IsOk() )
|
if( !fn.IsOk() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( !IsWritable( fn ) )
|
if( !fn.IsDirWritable() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PROJECT_FILE& project = Prj().GetProjectFile();
|
PROJECT_FILE& project = Prj().GetProjectFile();
|
||||||
|
|
Loading…
Reference in New Issue