diff --git a/common/settings/json_settings.cpp b/common/settings/json_settings.cpp index 3af724c933..5f54774d13 100644 --- a/common/settings/json_settings.cpp +++ b/common/settings/json_settings.cpp @@ -326,6 +326,14 @@ bool JSON_SETTINGS::SaveToFile( const wxString& aDirectory, bool aForce ) return false; } + // Ensure the path exists, and create it if not. + if( !path.DirExists() && !path.Mkdir() ) + { + wxLogTrace( traceSettings, "Warning: could not create path %s, can't save %s", + path.GetPath(), GetFullFilename() ); + return false; + } + if( ( path.FileExists() && !path.IsFileWritable() ) || ( !path.FileExists() && !path.IsDirWritable() ) ) { @@ -353,13 +361,6 @@ bool JSON_SETTINGS::SaveToFile( const wxString& aDirectory, bool aForce ) return false; } - if( !path.DirExists() && !path.Mkdir() ) - { - wxLogTrace( traceSettings, "Warning: could not create path %s, can't save %s", - path.GetPath(), GetFullFilename() ); - return false; - } - wxLogTrace( traceSettings, "Saving %s", GetFullFilename() ); LOCALE_IO dummy; @@ -448,7 +449,7 @@ nlohmann::json::json_pointer JSON_SETTINGS::PointerFromString( std::string aPath } -bool JSON_SETTINGS::SetIfPresent( const nlohmann::json& aObj, const std::string& aPath, +bool JSON_SETTINGS::SetIfPresent( const nlohmann::json& aObj, const std::string& aPath, wxString& aTarget ) { nlohmann::json::json_pointer ptr = PointerFromString( aPath ); @@ -463,7 +464,7 @@ bool JSON_SETTINGS::SetIfPresent( const nlohmann::json& aObj, const std::string& } -bool JSON_SETTINGS::SetIfPresent( const nlohmann::json& aObj, const std::string& aPath, +bool JSON_SETTINGS::SetIfPresent( const nlohmann::json& aObj, const std::string& aPath, bool& aTarget ) { nlohmann::json::json_pointer ptr = PointerFromString( aPath ); @@ -478,7 +479,7 @@ bool JSON_SETTINGS::SetIfPresent( const nlohmann::json& aObj, const std::string& } -bool JSON_SETTINGS::SetIfPresent( const nlohmann::json& aObj, const std::string& aPath, +bool JSON_SETTINGS::SetIfPresent( const nlohmann::json& aObj, const std::string& aPath, int& aTarget ) { nlohmann::json::json_pointer ptr = PointerFromString( aPath ); @@ -493,7 +494,7 @@ bool JSON_SETTINGS::SetIfPresent( const nlohmann::json& aObj, const std::string& } -bool JSON_SETTINGS::SetIfPresent( const nlohmann::json& aObj, const std::string& aPath, +bool JSON_SETTINGS::SetIfPresent( const nlohmann::json& aObj, const std::string& aPath, unsigned int& aTarget ) { nlohmann::json::json_pointer ptr = PointerFromString( aPath ); diff --git a/common/settings/settings_manager.cpp b/common/settings/settings_manager.cpp index 1c203057e1..6eaeb39ff6 100644 --- a/common/settings/settings_manager.cpp +++ b/common/settings/settings_manager.cpp @@ -326,10 +326,6 @@ void SETTINGS_MANAGER::SaveColorSettings( COLOR_SETTINGS* aSettings, const std:: ( *aSettings )[ptr].update( backup ); aSettings->Load(); - // Ensure the folder to store the config exists: - if( !wxDir::Exists( SETTINGS_MANAGER::GetColorSettingsPath() ) ) - wxDir::Make( SETTINGS_MANAGER::GetColorSettingsPath() ); - aSettings->SaveToFile( path, true ); }