Don't rely on exception processing for normal flow.
Also make sure when we do update the json in the parent to use the form that will create the object if it doesn't already exist.
This commit is contained in:
parent
fb46cd8bc5
commit
38312f0aca
|
@ -115,37 +115,37 @@ bool NESTED_SETTINGS::SaveToFile( const wxString& aDirectory, bool aForce )
|
||||||
if( !m_parent )
|
if( !m_parent )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
bool modified = Store();
|
bool modified = Store();
|
||||||
|
|
||||||
try
|
auto jsonObjectInParent = m_parent->GetJson( m_path );
|
||||||
{
|
|
||||||
nlohmann::json patch = nlohmann::json::diff( *m_internals,
|
|
||||||
m_parent->m_internals->Get<nlohmann::json>( m_path ) );
|
|
||||||
|
|
||||||
modified |= !patch.empty();
|
if( !jsonObjectInParent )
|
||||||
}
|
modified = true;
|
||||||
catch( ... )
|
else if( !nlohmann::json::diff( *m_internals, jsonObjectInParent.value() ).empty() )
|
||||||
{
|
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
|
||||||
|
|
||||||
if( !modified && !aForce )
|
if( modified || aForce )
|
||||||
return false;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
m_parent->m_internals->At( m_path ).update( *m_internals );
|
( *m_parent->m_internals )[m_path].update( *m_internals );
|
||||||
|
|
||||||
wxLogTrace( traceSettings, "Stored NESTED_SETTINGS %s with schema %d",
|
wxLogTrace( traceSettings, "Stored NESTED_SETTINGS %s with schema %d",
|
||||||
GetFilename(), m_schemaVersion );
|
GetFilename(),
|
||||||
|
m_schemaVersion );
|
||||||
|
}
|
||||||
|
|
||||||
|
return modified;
|
||||||
}
|
}
|
||||||
catch( ... )
|
catch( ... )
|
||||||
{
|
{
|
||||||
wxLogTrace( traceSettings, "NESTED_SETTINGS %s: Could not store to %s at %s",
|
wxLogTrace( traceSettings, "NESTED_SETTINGS %s: Could not store to %s at %s",
|
||||||
m_filename, m_parent->GetFilename(), m_path );
|
m_filename,
|
||||||
}
|
m_parent->GetFilename(),
|
||||||
|
m_path );
|
||||||
|
|
||||||
return modified;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue