Allow for settings to be added during load

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14691

(cherry picked from commit 2ab47ee1e9)
This commit is contained in:
Jon Evans 2023-05-07 08:48:07 -04:00 committed by Alex
parent 3894314ab2
commit f9b641b24d
1 changed files with 11 additions and 2 deletions

View File

@ -109,8 +109,17 @@ void SETTINGS_MANAGER::Load()
// TODO(JE) We should check for dirty settings here and write them if so, because
// Load() could be called late in the application lifecycle
for( auto&& settings : m_settings )
settings->LoadFromFile( GetPathForSettingsFile( settings.get() ) );
std::vector<JSON_SETTINGS*> toLoad;
// Cache a copy of raw pointers; m_settings may be modified during the load loop
std::transform( m_settings.begin(), m_settings.end(), std::back_inserter( toLoad ),
[]( std::unique_ptr<JSON_SETTINGS>& aSettings )
{
return aSettings.get();
} );
for( JSON_SETTINGS* settings : toLoad )
settings->LoadFromFile( GetPathForSettingsFile( settings ) );
}