Fixed crash while re-opening application window

pull/62/head
parent 61390454fd
commit 9a8c54c0a8

@ -918,7 +918,7 @@ dictionary *yon_scan_desktops(){
} }
if (apps_dict) return apps_dict; if (apps_dict) return apps_dict;
} }
static apps *scanned_application = NULL;
apps *yon_apps_scan_and_parse_desktops(int *sizef) apps *yon_apps_scan_and_parse_desktops(int *sizef)
{ {
int size = 0; int size = 0;
@ -941,63 +941,66 @@ apps *yon_apps_scan_and_parse_desktops(int *sizef)
apps tempapp; apps tempapp;
GKeyFile *gfile = g_key_file_new(); GKeyFile *gfile = g_key_file_new();
GError *err = NULL; GError *err = NULL;
g_key_file_load_from_file(gfile, path, G_KEY_FILE_KEEP_TRANSLATIONS, NULL); g_key_file_load_from_file(gfile, path, G_KEY_FILE_KEEP_TRANSLATIONS, &err);
char *Type = g_key_file_get_string(gfile, "Desktop Entry", "Type", &err); if (!err){
if (err) char *Type = g_key_file_get_string(gfile, "Desktop Entry", "Type", &err);
{ if (err)
printf("%s\n", err->message); {
} else { printf("%s\n", err->message);
if (strcmp(Type, "Application") == 0) } else {
tempapp.Type = 1; if (strcmp(Type, "Application") == 0)
else if (strcmp(Type, "pyApplication") == 0) tempapp.Type = 1;
tempapp.Type = 2; else if (strcmp(Type, "pyApplication") == 0)
else tempapp.Type = 2;
continue;
tempapp.Name = g_key_file_get_locale_string(gfile, "Desktop Entry", "Name", setlocale(LC_ALL, NULL), NULL);
if (tempapp.Name == NULL)
continue;
tempapp.Categories = g_key_file_get_string(gfile, "Desktop Entry", "Categories", NULL);
if (tempapp.Categories == NULL)
continue;
tempapp.Exec = g_key_file_get_string(gfile, "Desktop Entry", "Exec", NULL);
if (tempapp.Exec == NULL)
continue;
tempapp.Icon = g_key_file_get_string(gfile, "Desktop Entry", "Icon", NULL);
if (tempapp.Icon == NULL)
continue;
tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "Pluggable", NULL);
if (!tempapp.Pluggable)
tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-XfcePluggable", NULL);
if (tempapp.Pluggable)
tempapp.DualPluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBLPluggable", NULL);
if (g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBL-SettingsManager-Hidden", NULL) == 0)
if (size == 0)
{
applist = (apps *)malloc(size + 1 * sizeof(apps));
applist[0].filename = yon_char_new(path);
applist[0].Name = yon_char_new(tempapp.Name);
applist[0].Categories = yon_char_new(tempapp.Categories);
applist[0].Exec = yon_char_new(tempapp.Exec);
applist[0].Icon = yon_char_new(tempapp.Icon);
applist[0].Type = tempapp.Type;
applist[0].Pluggable = tempapp.Pluggable;
applist[0].DualPluggable = tempapp.DualPluggable;
size++;
}
else else
{ continue;
applist = (apps *)realloc(applist, (size + 1) * sizeof(apps)); tempapp.Name = g_key_file_get_locale_string(gfile, "Desktop Entry", "Name", setlocale(LC_ALL, NULL), NULL);
applist[size].filename = yon_char_new(path); if (tempapp.Name == NULL)
applist[size].Name = yon_char_new(tempapp.Name); continue;
applist[size].Categories = yon_char_new(tempapp.Categories); tempapp.Categories = g_key_file_get_string(gfile, "Desktop Entry", "Categories", NULL);
applist[size].Exec = yon_char_new(tempapp.Exec); if (tempapp.Categories == NULL)
applist[size].Icon = yon_char_new(tempapp.Icon); continue;
applist[size].Pluggable = tempapp.Pluggable; tempapp.Exec = g_key_file_get_string(gfile, "Desktop Entry", "Exec", NULL);
applist[size].DualPluggable = tempapp.DualPluggable; if (tempapp.Exec == NULL)
applist[size].Type = tempapp.Type; continue;
size++; tempapp.Icon = g_key_file_get_string(gfile, "Desktop Entry", "Icon", NULL);
} if (tempapp.Icon == NULL)
continue;
tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "Pluggable", NULL);
if (!tempapp.Pluggable)
tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-XfcePluggable", NULL);
if (tempapp.Pluggable)
tempapp.DualPluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBLPluggable", NULL);
if (g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBL-SettingsManager-Hidden", NULL) == 0)
if (size == 0)
{
applist = (apps *)malloc(size + 1 * sizeof(apps));
applist[0].filename = yon_char_new(path);
applist[0].Name = yon_char_new(tempapp.Name);
applist[0].Categories = yon_char_new(tempapp.Categories);
applist[0].Exec = yon_char_new(tempapp.Exec);
applist[0].Icon = yon_char_new(tempapp.Icon);
applist[0].Type = tempapp.Type;
applist[0].Pluggable = tempapp.Pluggable;
applist[0].DualPluggable = tempapp.DualPluggable;
size++;
}
else
{
applist = (apps *)realloc(applist, (size + 1) * sizeof(apps));
applist[size].filename = yon_char_new(path);
applist[size].Name = yon_char_new(tempapp.Name);
applist[size].Categories = yon_char_new(tempapp.Categories);
applist[size].Exec = yon_char_new(tempapp.Exec);
applist[size].Icon = yon_char_new(tempapp.Icon);
applist[size].Pluggable = tempapp.Pluggable;
applist[size].DualPluggable = tempapp.DualPluggable;
applist[size].Type = tempapp.Type;
size++;
}
}
} }
g_key_file_free(gfile); g_key_file_free(gfile);
} }
} }
@ -1005,6 +1008,7 @@ apps *yon_apps_scan_and_parse_desktops(int *sizef)
} }
} }
*sizef = size; *sizef = size;
scanned_application = applist;
return applist; return applist;
}; };
@ -1098,7 +1102,7 @@ char *yon_app_chooser_open_with_sections(char *section_name, char *section_filte
} }
va_end(args); va_end(args);
int size; int size;
apps *app_list = yon_apps_scan_and_parse_desktops(&size); apps *app_list = scanned_application ? scanned_application : yon_apps_scan_and_parse_desktops(&size);
int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store),&iter); int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store),&iter);
for (; valid; valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store),&iter)){ for (; valid; valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store),&iter)){
char *cur_categories; char *cur_categories;

Loading…
Cancel
Save