Fixed bug where application crashed when trying to launch it without sections in config file

pull/9/head
parent 01d206f30c
commit db2579df2a

@ -946,11 +946,7 @@ int check_categories(apps app, char *catstocheck){
int setup_config(){
FILE *file;
GError *err=NULL;
main_config.sections=malloc(sizeof(dictionary));
main_config.sections->data=NULL;
main_config.sections->next=NULL;
main_config.sections->prev=NULL;
main_config.sections->first=NULL;
main_config.sections=yon_dictionary_create_empty();
GKeyFile *configfile = g_key_file_new();
char *pth=malloc(7+strlen(UserConfigPath)+strlen(getlogin()));
sprintf(pth,"%s%s%s","/home/",getlogin(),UserConfigPath);
@ -997,7 +993,7 @@ int setup_config(){
gsize length=0;
char **a=g_key_file_get_keys(configfile,"sections",&length,NULL);
if (!a){yon_set_default_sections(&main_config.sections);} else {
if (!a){yon_set_default_sections(main_config.sections);} else {
for (int i=0;i<length;i++){
char *cats=g_key_file_get_string(configfile,"sections",a[i],NULL);
main_config.sections=yon_section_new(main_config.sections,a[i], cats);
@ -1103,38 +1099,14 @@ char *yon_char_divide_search(char *source, char* dividepos, int delete_divider){
return cut;
}
void yon_set_default_sections(dictionary **section){
*section=malloc(sizeof(dictionary));
IconSection *sec=malloc(sizeof(IconSection));
sec->section="Personal";
sec->categories="X-UBL-SettingsManager;X-UBL-PersonalSettings;";
(*section)->data=sec;
(*section)->first=*section;
(*section)->next=malloc(sizeof(dictionary));
(*section)->next->prev=*section;
(*section)->next->first=(*section)->first;
*section=(*section)->next;
sec=malloc(sizeof(IconSection));
sec->section="Hardware";
sec->categories="X-UBL-SettingsManager;X-UBL-HardwareSettings;";
(*section)->data=sec;
(*section)->next=malloc(sizeof(dictionary));
(*section)->next->prev=*section;
(*section)->next->first=(*section)->first;
*section=(*section)->next;
sec=malloc(sizeof(IconSection));
sec->section="System";
sec->categories="X-UBL-SettingsManager;X-UBL-SystemSettings;";
(*section)->data=sec;
(*section)->next=malloc(sizeof(dictionary));
(*section)->next->prev=*section;
(*section)->next->first=(*section)->first;
*section=(*section)->next;
sec=malloc(sizeof(IconSection));
sec->section="Misc";
sec->categories="X-UBL-SettingsManager;";
(*section)->data=sec;
*section=(*section)->first;
void yon_set_default_sections(dictionary *section){
yon_section_new(section,"Personal","X-UBL-SettingsManager;X-UBL-PersonalSettings;");
section=yon_dictionary_create_conneced(section);
yon_section_new(section,"Hardware","X-UBL-SettingsManager;X-UBL-HardwareSettings;");
section=yon_dictionary_create_conneced(section);
yon_section_new(section,"System","X-UBL-SettingsManager;X-UBL-SystemSettings;");
section=yon_dictionary_create_conneced(section);
yon_section_new(section,"Misc","X-UBL-SettingsManager;X-UBL-MiscSettings;");
}
IVGraphicals *yon_create_single_section_IV(char *name,char *cats){
@ -1230,7 +1202,7 @@ void yon_check_path(char *path){
dictionary *yon_section_new(dictionary *section, char *section_name, char *categories){
section->next=NULL;
IconSection *sct=malloc(sizeof(IconSection));
dictionary *dict=malloc(sizeof(dictionary));
dictionary *dict=yon_dictionary_create_empty();//malloc(sizeof(dictionary));
sct->section=section_name;
sct->categories=categories;
dict->data=sct;

@ -202,7 +202,7 @@ dictionary *yon_theme_new(dictionary **widgetss, GtkBuilder *builder, char *them
char *yon_char_get_augumented(char *source, char *append);
char *yon_cut(char *source, int size, int startpos);
int yon_set_sections(IconSection *section);
void yon_set_default_sections(dictionary **section);
void yon_set_default_sections(dictionary *section);
char *yon_char_divide_search(char *source, char* dividepos, int delete_divider);
char *yon_char_divide(char *source, int dividepos);
dictionary *yon_section_new(dictionary *section, char *section_name, char *categories);

Loading…
Cancel
Save