Don't nag when we can't save project settings

Fixes https://gitlab.com/kicad/code/kicad/-/issues/4164
This commit is contained in:
Jon Evans 2020-07-16 22:56:02 -04:00
parent 5444a1b4b0
commit 5401f06fce
2 changed files with 17 additions and 7 deletions

View File

@ -105,16 +105,20 @@ bool JSON_SETTINGS::LoadFromFile( const std::string& aDirectory )
auto migrateFromLegacy = [&] ( wxFileName& aPath ) {
// Backup and restore during migration so that the original can be mutated if convenient
bool backed_up = false;
wxFileName temp;
temp.AssignTempFileName( aPath.GetFullPath() );
bool backed_up = true;
if( !wxCopyFile( aPath.GetFullPath(), temp.GetFullPath() ) )
if( aPath.IsDirWritable() )
{
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() );
backed_up = false;
}
else
backed_up = true;
}
wxConfigBase::DontCreateOnDemand();
@ -307,6 +311,12 @@ bool JSON_SETTINGS::SaveToFile( const std::string& aDirectory, bool aForce )
return false;
}
if( !path.IsFileWritable() )
{
wxLogTrace( traceSettings, "File for %s is read-only; not saving", GetFullFilename() );
return false;
}
bool modified = false;
for( auto settings : m_nested_settings )

View File

@ -137,7 +137,7 @@ void PCB_EDIT_FRAME::SaveProjectSettings()
if( !fn.IsOk() )
return;
if( !IsWritable( fn ) )
if( !fn.IsDirWritable() )
return;
PROJECT_FILE& project = Prj().GetProjectFile();