Preserve unknown keys in JSON_SETTINGS
Fixes https://gitlab.com/kicad/code/kicad/-/issues/13847
This commit is contained in:
parent
4917abe655
commit
f076f6fb46
|
@ -269,6 +269,9 @@ bool JSON_SETTINGS::LoadFromFile( const wxString& aDirectory )
|
|||
/* allow_exceptions = */ true,
|
||||
/* ignore_comments = */ true );
|
||||
|
||||
// Save whatever we loaded, before doing any migration etc
|
||||
m_internals->m_original = *static_cast<nlohmann::json*>( m_internals.get() );
|
||||
|
||||
// If parse succeeds, check if schema migration is required
|
||||
int filever = -1;
|
||||
|
||||
|
@ -438,10 +441,14 @@ bool JSON_SETTINGS::SaveToFile( const wxString& aDirectory, bool aForce )
|
|||
LOCALE_IO dummy;
|
||||
bool success = true;
|
||||
|
||||
nlohmann::json toSave = m_internals->m_original;
|
||||
|
||||
toSave.update( m_internals->begin(), m_internals->end(), /* merge_objects = */ true );
|
||||
|
||||
try
|
||||
{
|
||||
std::stringstream buffer;
|
||||
buffer << std::setw( 2 ) << *m_internals << std::endl;
|
||||
buffer << std::setw( 2 ) << toSave << std::endl;
|
||||
|
||||
wxFFileOutputStream fileStream( path.GetFullPath(), "wb" );
|
||||
|
||||
|
|
|
@ -73,6 +73,10 @@ public:
|
|||
nlohmann::json::json_pointer root( "" );
|
||||
this->nlohmann::json::operator[]( root ) = aOther.nlohmann::json::operator[]( root );
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
nlohmann::json m_original;
|
||||
};
|
||||
|
||||
#endif // KICAD_JSON_SETTINGS_INTERNALS_H
|
||||
|
|
Loading…
Reference in New Issue