Store "cfg" on stack and destory it once finished
This commit is contained in:
parent
6bcfbd66cf
commit
667ef4461e
@ -47,27 +47,26 @@ void themeStartup(ThemePreset preset) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
theme_t *themeDefault;
|
theme_t *themeDefault;
|
||||||
config_t *cfg = NULL;
|
config_t cfg = {0};
|
||||||
cfg = (config_t *) malloc(sizeof(config_t));
|
config_init(&cfg);
|
||||||
config_init(cfg);
|
|
||||||
config_setting_t *theme;
|
config_setting_t *theme;
|
||||||
color_t text, frontWave, middleWave, backWave, background, highlight, separator;
|
color_t text, frontWave, middleWave, backWave, background, highlight, separator;
|
||||||
int waveBlending;
|
int waveBlending;
|
||||||
const char *AText, *BText;
|
const char *AText, *BText;
|
||||||
bool good_cfg=config_read_file(cfg, "/hbtheme.cfg");
|
bool good_cfg=config_read_file(&cfg, "/hbtheme.cfg");
|
||||||
|
|
||||||
switch (preset) {
|
switch (preset) {
|
||||||
case THEME_PRESET_LIGHT:
|
case THEME_PRESET_LIGHT:
|
||||||
default:
|
default:
|
||||||
themeDefault = &themeLight;
|
themeDefault = &themeLight;
|
||||||
if (good_cfg)
|
if (good_cfg)
|
||||||
theme = config_lookup(cfg, "lightTheme");
|
theme = config_lookup(&cfg, "lightTheme");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case THEME_PRESET_DARK:
|
case THEME_PRESET_DARK:
|
||||||
themeDefault = &themeDark;
|
themeDefault = &themeDark;
|
||||||
if (good_cfg)
|
if (good_cfg)
|
||||||
theme = config_lookup(cfg, "darkTheme");
|
theme = config_lookup(&cfg, "darkTheme");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,4 +113,5 @@ void themeStartup(ThemePreset preset) {
|
|||||||
} else {
|
} else {
|
||||||
themeCurrent = *themeDefault;
|
themeCurrent = *themeDefault;
|
||||||
}
|
}
|
||||||
|
config_destroy(&cfg);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user