plug leaks. Fixes bug #396069.

2007-03-04  Jens Granseuer  <jensgr@gmx.net>

	* gnome-wp-capplet.c: (gnome_wp_add_images),
	(gnome_wp_file_open_dialog), (bg_properties_dragged_image),
	(gnome_wp_main_quit), (gnome_wp_scale_type_changed),
	(gnome_wp_shade_type_changed), (gnome_wp_load_stuffs),
	(gnome_wp_options_changed), (gnome_wp_shading_changed),
	(wallpaper_properties_init), (main):
	* gnome-wp-item.c: (gnome_wp_item_new),
	(gnome_wp_item_get_thumbnail):
	* gnome-wp-xml.c: (gnome_wp_load_legacy), (gnome_wp_xml_load_xml),
	(gnome_wp_list_flatten), (gnome_wp_xml_save_list): plug leaks.
	Fixes bug #396069.

svn path=/trunk/; revision=7361
This commit is contained in:
Jens Granseuer 2007-03-04 20:42:33 +00:00 committed by Jens Granseuer
parent 36c9732484
commit 7227b2dafd
4 changed files with 59 additions and 31 deletions

View file

@ -1,3 +1,17 @@
2007-03-04 Jens Granseuer <jensgr@gmx.net>
* gnome-wp-capplet.c: (gnome_wp_add_images),
(gnome_wp_file_open_dialog), (bg_properties_dragged_image),
(gnome_wp_main_quit), (gnome_wp_scale_type_changed),
(gnome_wp_shade_type_changed), (gnome_wp_load_stuffs),
(gnome_wp_options_changed), (gnome_wp_shading_changed),
(wallpaper_properties_init), (main):
* gnome-wp-item.c: (gnome_wp_item_new),
(gnome_wp_item_get_thumbnail):
* gnome-wp-xml.c: (gnome_wp_load_legacy), (gnome_wp_xml_load_xml),
(gnome_wp_list_flatten), (gnome_wp_xml_save_list): plug leaks.
Fixes bug #396069.
2007-01-29 Kjartan Maraas <kmaraas@gnome.org>
* gnome-wp-capplet.c: (wallpaper_properties_init):

View file

@ -131,10 +131,12 @@ static void gnome_wp_add_images (GnomeWPCapplet * capplet,
gdk_window_set_cursor (capplet->window->window, cursor);
gdk_cursor_unref (cursor);
if (images != NULL) {
for (; images != NULL; images = images->next) {
item = gnome_wp_add_image (capplet, images->data);
}
while (images != NULL) {
gchar * uri = images->data;
item = gnome_wp_add_image (capplet, uri);
images = g_slist_remove (images, uri);
g_free (uri);
}
gdk_window_set_cursor (capplet->window->window, NULL);
@ -152,7 +154,6 @@ static void gnome_wp_file_open_dialog (GtkWidget * widget,
case GTK_RESPONSE_OK:
files = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (capplet->filesel));
gnome_wp_add_images (capplet, files);
g_slist_free (files);
case GTK_RESPONSE_CANCEL:
default:
gtk_widget_hide (capplet->filesel);
@ -189,7 +190,6 @@ static void bg_properties_dragged_image (GtkWidget * widget,
gdk_window_set_cursor (capplet->window->window, NULL);
}
gnome_vfs_uri_list_free (uris);
g_slist_free (realuris);
}
}
@ -381,7 +381,8 @@ void gnome_wp_main_quit (GnomeWPCapplet * capplet) {
g_object_unref (capplet->thumbs);
g_hash_table_destroy (capplet->wphash);
g_object_unref (capplet->client);
g_free (capplet);
gtk_main_quit ();
}
@ -423,6 +424,9 @@ static void gnome_wp_scale_type_changed (GtkOptionMenu * option_menu,
if (item == NULL) {
return;
}
g_free (item->options);
switch (gnome_wp_option_menu_get (GTK_OPTION_MENU (capplet->wp_opts))) {
case GNOME_WP_SCALE_TYPE_CENTERED:
item->options = g_strdup ("centered");
@ -437,9 +441,8 @@ static void gnome_wp_scale_type_changed (GtkOptionMenu * option_menu,
item->options = g_strdup ("zoom");
break;
case GNOME_WP_SCALE_TYPE_TILED:
item->options = g_strdup ("wallpaper");
break;
default:
item->options = g_strdup ("wallpaper");
break;
}
pixbuf = gnome_wp_item_get_thumbnail (item, capplet->thumbs);
@ -473,6 +476,8 @@ static void gnome_wp_shade_type_changed (GtkOptionMenu * option_menu,
return;
}
g_free (item->shade_type);
switch (gnome_wp_option_menu_get (GTK_OPTION_MENU (capplet->color_opt))) {
case GNOME_WP_SHADE_TYPE_HORIZ:
item->shade_type = g_strdup ("horizontal-gradient");
@ -483,11 +488,10 @@ static void gnome_wp_shade_type_changed (GtkOptionMenu * option_menu,
gtk_widget_show (capplet->sc_picker);
break;
case GNOME_WP_SHADE_TYPE_SOLID:
default:
item->shade_type = g_strdup ("solid");
gtk_widget_hide (capplet->sc_picker);
break;
default:
break;
}
pixbuf = gnome_wp_item_get_thumbnail (item, capplet->thumbs);
gtk_list_store_set (GTK_LIST_STORE (capplet->model), &iter,
@ -646,7 +650,6 @@ static gboolean gnome_wp_load_stuffs (void * data) {
if (capplet->uri_list) {
gnome_wp_add_images (capplet, capplet->uri_list);
g_slist_free (capplet->uri_list);
}
return FALSE;
@ -728,6 +731,7 @@ static void gnome_wp_options_changed (GConfClient * client, guint id,
item = g_hash_table_lookup (capplet->wphash, wpfile);
if (item != NULL) {
g_free (item->options);
item->options = g_strdup (gconf_value_get_string (entry->value));
gnome_wp_option_menu_set (capplet, item->options, FALSE);
}
@ -753,6 +757,7 @@ static void gnome_wp_shading_changed (GConfClient * client, guint id,
item = g_hash_table_lookup (capplet->wphash, wpfile);
if (item != NULL) {
g_free (item->shade_type);
item->shade_type = g_strdup (gconf_value_get_string (entry->value));
gnome_wp_option_menu_set (capplet, item->shade_type, TRUE);
}
@ -865,10 +870,7 @@ static void wallpaper_properties_init (void) {
" style \"wp-dialog-defaults\"\n");
capplet = g_new0 (GnomeWPCapplet, 1);
if (capplet->client == NULL) {
capplet->client = gconf_client_get_default ();
}
capplet->client = gconf_client_get_default ();
gconf_client_add_dir (capplet->client, WP_KEYBOARD_PATH,
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
@ -896,10 +898,7 @@ static void wallpaper_properties_init (void) {
(GConfClientNotifyFunc) gnome_wp_color2_changed,
capplet, NULL, NULL);
capplet->wphash = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free,
(GDestroyNotify)
gnome_wp_item_free);
capplet->wphash = g_hash_table_new (g_str_hash, g_str_equal);
capplet->thumbs = gnome_thumbnail_factory_new (GNOME_THUMBNAIL_SIZE_NORMAL);
@ -1028,8 +1027,9 @@ static void wallpaper_properties_init (void) {
const gchar ** p;
for (p = (const gchar **) command_line_files; *p != NULL; p++) {
capplet->uri_list = g_slist_append (capplet->uri_list, (gchar *) *p);
capplet->uri_list = g_slist_append (capplet->uri_list, g_strdup (*p));
}
g_strfreev (command_line_files);
}
g_idle_add (gnome_wp_load_stuffs, capplet);
@ -1145,5 +1145,7 @@ gint main (gint argc, gchar *argv[]) {
gtk_main ();
g_object_unref (program);
return 0;
}

View file

@ -70,7 +70,7 @@ GnomeWPItem * gnome_wp_item_new (const gchar * filename,
}
gnome_wp_item_update_description (item);
g_hash_table_insert (wallpapers, g_strdup (item->filename), item);
g_hash_table_insert (wallpapers, item->filename, item);
} else {
gnome_wp_item_free (item);
item = NULL;
@ -272,9 +272,12 @@ GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item,
pixbuf = gdk_pixbuf_new_from_file (thumbnail_filename, NULL);
if (pixbuf != NULL) {
g_free (item->fileinfo->thumburi);
item->fileinfo->thumburi = thumbnail_filename;
thumbnail_filename = NULL;
}
g_free (thumbnail_filename);
}
g_free (escaped_path);

View file

@ -88,6 +88,8 @@ static void gnome_wp_load_legacy (GnomeWPCapplet * capplet) {
g_free (foo);
}
}
g_free (filename);
}
static void gnome_wp_xml_load_xml (GnomeWPCapplet * capplet,
@ -144,7 +146,9 @@ static void gnome_wp_xml_load_xml (GnomeWPCapplet * capplet,
} else {
for (i = 0; syslangs[i] != NULL; i++) {
if (!strcmp (syslangs[i], (gchar *)nodelang)) {
g_free (wp->name);
wp->name = g_strdup (g_strstrip ((gchar *)wpa->last->content));
break;
}
}
}
@ -192,6 +196,7 @@ static void gnome_wp_xml_load_xml (GnomeWPCapplet * capplet,
continue;
}
} else {
gnome_wp_item_free (wp);
continue;
}
@ -224,7 +229,7 @@ static void gnome_wp_xml_load_xml (GnomeWPCapplet * capplet,
}
gnome_wp_item_update_description (wp);
g_hash_table_insert (capplet->wphash, g_strdup (wp->filename), wp);
g_hash_table_insert (capplet->wphash, wp->filename, wp);
} else {
gnome_wp_item_free (wp);
}
@ -341,21 +346,23 @@ void gnome_wp_xml_load_list (GnomeWPCapplet * capplet) {
}
static void gnome_wp_list_flatten (const gchar * key, GnomeWPItem * item,
GList ** list) {
GSList ** list) {
g_return_if_fail (key != NULL);
g_return_if_fail (item != NULL);
*list = g_list_append (*list, item);
*list = g_slist_prepend (*list, item);
}
void gnome_wp_xml_save_list (GnomeWPCapplet * capplet) {
xmlDoc * wplist;
xmlNode * root, * wallpaper, * item;
GList * list = NULL, * wp = NULL;
GSList * list = NULL;
gchar * wpfile;
g_hash_table_foreach (capplet->wphash,
(GHFunc) gnome_wp_list_flatten, &list);
g_hash_table_foreach_remove (capplet->wphash,
(GHRFunc) gnome_wp_list_flatten, &list);
g_hash_table_destroy (capplet->wphash);
list = g_slist_reverse (list);
wpfile = g_build_filename (g_get_home_dir (),
"/.gnome2",
@ -369,8 +376,8 @@ void gnome_wp_xml_save_list (GnomeWPCapplet * capplet) {
root = xmlNewNode (NULL, (xmlChar *)"wallpapers");
xmlDocSetRootElement (wplist, root);
for (wp = list; wp != NULL; wp = wp->next) {
GnomeWPItem * wpitem = wp->data;
while (list != NULL) {
GnomeWPItem * wpitem = list->data;
const char * none = "(none)";
gchar * filename;
@ -390,9 +397,11 @@ void gnome_wp_xml_save_list (GnomeWPCapplet * capplet) {
item = xmlNewTextChild (wallpaper, NULL, (xmlChar *)"pcolor", (xmlChar *)wpitem->pri_color);
item = xmlNewTextChild (wallpaper, NULL, (xmlChar *)"scolor", (xmlChar *)wpitem->sec_color);
g_free (filename);
list = g_slist_remove (list, wpitem);
gnome_wp_item_free (wpitem);
}
xmlSaveFormatFile (wpfile, wplist, 1);
xmlFreeDoc (wplist);
g_free (wpfile);
}