test fix for crash at desktop files loading

pull/62/head
parent 8228f93d24
commit aeb9bbb0a2

@ -904,57 +904,58 @@ apps *yon_apps_scan_and_parse_desktops(int *sizef)
if (err) if (err)
{ {
printf("%s\n", err->message); printf("%s\n", err->message);
} } else {
if (strcmp(Type, "Application") == 0) if (strcmp(Type, "Application") == 0)
tempapp.Type = 1; tempapp.Type = 1;
else if (strcmp(Type, "pyApplication") == 0) else if (strcmp(Type, "pyApplication") == 0)
tempapp.Type = 2; tempapp.Type = 2;
else
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++;
}
}
} }
} }
} }
@ -1026,6 +1027,7 @@ char *yon_app_chooser_open_with_sections(char *section_name, char *section_filte
g_object_ref(box); g_object_ref(box);
gtk_container_remove(GTK_CONTAINER(window),box); gtk_container_remove(GTK_CONTAINER(window),box);
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),box,1,1,5); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),box,1,1,5);
(gtk_dialog_get_content_area(GTK_DIALOG(dialog)),0);
GtkWidget *main_tree = GTK_WIDGET(gtk_builder_get_object(builder,"MainTree")); GtkWidget *main_tree = GTK_WIDGET(gtk_builder_get_object(builder,"MainTree"));
GtkTreeStore *store = GTK_TREE_STORE(gtk_builder_get_object(builder,"treestore1")); GtkTreeStore *store = GTK_TREE_STORE(gtk_builder_get_object(builder,"treestore1"));
va_list args; va_list args;

Loading…
Cancel
Save