Create the built-in colors in the constructor

This is needed so Python scripts can get built-in colors using the
SETTINGS_MANAGER.GetColorSettings() member.
Otherwise calling it with a built-in name crashes.
This commit is contained in:
Salvador E. Tropea 2023-02-17 13:32:11 -03:00
parent fd4a0dbedf
commit aee6d9d01c
2 changed files with 15 additions and 2 deletions

View File

@ -66,6 +66,10 @@ SETTINGS_MANAGER::SETTINGS_MANAGER( bool aHeadless ) :
// create the common settings shared by all applications. Not loaded immediately
m_common_settings = RegisterSettings( new COMMON_SETTINGS, false );
// Create the built-in color settings
// Here to allow the Python API to access the built-in colors
registerBuiltinColorSettings();
}
SETTINGS_MANAGER::~SETTINGS_MANAGER()
@ -305,11 +309,17 @@ COLOR_SETTINGS* SETTINGS_MANAGER::GetMigratedColorSettings()
}
void SETTINGS_MANAGER::registerBuiltinColorSettings()
{
for( COLOR_SETTINGS* settings : COLOR_SETTINGS::CreateBuiltinColorSettings() )
m_color_settings[settings->GetFilename()] = RegisterSettings( settings, false );
}
void SETTINGS_MANAGER::loadAllColorSettings()
{
// Create the built-in color settings
for( COLOR_SETTINGS* settings : COLOR_SETTINGS::CreateBuiltinColorSettings() )
m_color_settings[settings->GetFilename()] = RegisterSettings( settings, false );
registerBuiltinColorSettings();
wxFileName third_party_path;
const ENV_VAR_MAP& env = Pgm().GetLocalEnvVariables();

View File

@ -414,6 +414,9 @@ private:
*/
bool unloadProjectFile( PROJECT* aProject, bool aSave );
// Helper to create built-in colors and register them
void registerBuiltinColorSettings();
private:
/// True if running outside a UI context