gtk/*: Use g_list_free_full() convenience function

This commit is contained in:
Javier Jardón 2012-01-02 04:20:59 +01:00
parent 6ad6f719c6
commit d005b01319
21 changed files with 37 additions and 87 deletions

View File

@ -2003,8 +2003,7 @@ gtk_drag_find_widget (GtkWidget *widget,
g_object_add_weak_pointer (G_OBJECT (parent), (gpointer *) &parent); g_object_add_weak_pointer (G_OBJECT (parent), (gpointer *) &parent);
} }
g_list_foreach (hierarchy, (GFunc) g_object_unref, NULL); g_list_free_full (hierarchy, g_object_unref);
g_list_free (hierarchy);
if (found) if (found)
return TRUE; return TRUE;

View File

@ -820,8 +820,7 @@ shortcuts_free (GtkFileChooserDefault *impl)
static void static void
pending_select_files_free (GtkFileChooserDefault *impl) pending_select_files_free (GtkFileChooserDefault *impl)
{ {
g_slist_foreach (impl->pending_select_files, (GFunc) g_object_unref, NULL); g_slist_free_full (impl->pending_select_files, g_object_unref);
g_slist_free (impl->pending_select_files);
impl->pending_select_files = NULL; impl->pending_select_files = NULL;
} }

View File

@ -734,10 +734,8 @@ blow_themes (GtkIconTheme *icon_theme)
if (priv->themes_valid) if (priv->themes_valid)
{ {
g_hash_table_destroy (priv->all_icons); g_hash_table_destroy (priv->all_icons);
g_list_foreach (priv->themes, (GFunc)theme_destroy, NULL); g_list_free_full (priv->themes, (GDestroyNotify) theme_destroy);
g_list_free (priv->themes); g_list_free_full (priv->dir_mtimes, (GDestroyNotify) free_dir_mtime);
g_list_foreach (priv->dir_mtimes, (GFunc)free_dir_mtime, NULL);
g_list_free (priv->dir_mtimes);
g_hash_table_destroy (priv->unthemed_icons); g_hash_table_destroy (priv->unthemed_icons);
} }
priv->themes = NULL; priv->themes = NULL;
@ -2021,8 +2019,7 @@ theme_destroy (IconTheme *theme)
g_free (theme->name); g_free (theme->name);
g_free (theme->example); g_free (theme->example);
g_list_foreach (theme->dirs, (GFunc)theme_dir_destroy, NULL); g_list_free_full (theme->dirs, (GDestroyNotify) theme_dir_destroy);
g_list_free (theme->dirs);
g_free (theme); g_free (theme);
} }
@ -2721,8 +2718,7 @@ gtk_icon_info_free (GtkIconInfo *icon_info)
g_free (icon_info->filename); g_free (icon_info->filename);
if (icon_info->loadable) if (icon_info->loadable)
g_object_unref (icon_info->loadable); g_object_unref (icon_info->loadable);
g_slist_foreach (icon_info->emblem_infos, (GFunc)gtk_icon_info_free, NULL); g_slist_free_full (icon_info->emblem_infos, (GDestroyNotify) gtk_icon_info_free);
g_slist_free (icon_info->emblem_infos);
if (icon_info->pixbuf) if (icon_info->pixbuf)
g_object_unref (icon_info->pixbuf); g_object_unref (icon_info->pixbuf);
if (icon_info->cache_pixbuf) if (icon_info->cache_pixbuf)

View File

@ -4768,8 +4768,7 @@ gtk_icon_view_set_model (GtkIconView *icon_view,
g_object_unref (icon_view->priv->model); g_object_unref (icon_view->priv->model);
g_list_foreach (icon_view->priv->items, (GFunc)gtk_icon_view_item_free, NULL); g_list_free_full (icon_view->priv->items, (GDestroyNotify) gtk_icon_view_item_free);
g_list_free (icon_view->priv->items);
icon_view->priv->items = NULL; icon_view->priv->items = NULL;
icon_view->priv->anchor_item = NULL; icon_view->priv->anchor_item = NULL;
icon_view->priv->cursor_item = NULL; icon_view->priv->cursor_item = NULL;
@ -5180,8 +5179,7 @@ gtk_icon_view_unselect_path (GtkIconView *icon_view,
* *
* To free the return value, use: * To free the return value, use:
* |[ * |[
* g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL); * g_list_free_full (list, (GDestroyNotify) gtk_tree_patch_free);
* g_list_free (list);
* ]| * ]|
* *
* Return value: (element-type GtkTreePath) (transfer full): A #GList containing a #GtkTreePath for each selected row. * Return value: (element-type GtkTreePath) (transfer full): A #GList containing a #GtkTreePath for each selected row.

View File

@ -2509,8 +2509,7 @@ parse_uri_markup (GtkLabel *label,
failed: failed:
g_markup_parse_context_free (context); g_markup_parse_context_free (context);
g_string_free (pdata.new_str, TRUE); g_string_free (pdata.new_str, TRUE);
g_list_foreach (pdata.links, (GFunc)link_free, NULL); g_list_free_full (pdata.links, (GDestroyNotify) link_free);
g_list_free (pdata.links);
gdk_color_free (pdata.link_color); gdk_color_free (pdata.link_color);
gdk_color_free (pdata.visited_link_color); gdk_color_free (pdata.visited_link_color);
@ -6267,8 +6266,7 @@ gtk_label_clear_links (GtkLabel *label)
if (!priv->select_info) if (!priv->select_info)
return; return;
g_list_foreach (priv->select_info->links, (GFunc)link_free, NULL); g_list_free_full (priv->select_info->links, (GDestroyNotify) link_free);
g_list_free (priv->select_info->links);
priv->select_info->links = NULL; priv->select_info->links = NULL;
priv->select_info->active_link = NULL; priv->select_info->active_link = NULL;
} }

View File

@ -490,8 +490,7 @@ gtk_paper_size_get_paper_sizes (gboolean include_custom)
list = g_list_prepend (list, gtk_paper_size_copy (size)); list = g_list_prepend (list, gtk_paper_size_copy (size));
} }
g_list_foreach (page_setups, (GFunc) g_object_unref, NULL); g_list_free_full (page_setups, g_object_unref);
g_list_free (page_setups);
} }
#endif #endif
for (i = 0; i < G_N_ELEMENTS (standard_names_offsets); ++i) for (i = 0; i < G_N_ELEMENTS (standard_names_offsets); ++i)

View File

@ -1540,8 +1540,7 @@ update_dialog_from_settings (GtkPrintUnixDialog *dialog)
else else
gtk_widget_hide (priv->advanced_page); gtk_widget_hide (priv->advanced_page);
g_list_foreach (groups, (GFunc) g_free, NULL); g_list_free_full (groups, g_free);
g_list_free (groups);
} }
static void static void

View File

@ -121,8 +121,7 @@ _gtk_query_set_mime_types (GtkQuery *query,
GList *l; GList *l;
gchar *mime_type; gchar *mime_type;
g_list_foreach (query->priv->mime_types, (GFunc)g_free, NULL); g_list_free_full (query->priv->mime_types, g_free);
g_list_free (query->priv->mime_types);
query->priv->mime_types = NULL; query->priv->mime_types = NULL;
for (l = mime_types; l; l = l->next) for (l = mime_types; l; l = l->next)

View File

@ -895,10 +895,7 @@ gtk_recent_chooser_get_uris (GtkRecentChooser *chooser,
if (length) if (length)
*length = i; *length = i;
g_list_foreach (items, g_list_free_full (items, (GDestroyNotify) gtk_recent_info_unref);
(GFunc) gtk_recent_info_unref,
NULL);
g_list_free (items);
return retval; return retval;
} }

View File

@ -629,12 +629,8 @@ gtk_recent_chooser_default_dispose (GObject *object)
impl->load_id = 0; impl->load_id = 0;
} }
if (impl->recent_items) g_list_free_full (impl->recent_items, (GDestroyNotify) gtk_recent_info_unref);
{ impl->recent_items = NULL;
g_list_foreach (impl->recent_items, (GFunc) gtk_recent_info_unref, NULL);
g_list_free (impl->recent_items);
impl->recent_items = NULL;
}
if (impl->manager && impl->manager_changed_id) if (impl->manager && impl->manager_changed_id)
{ {
@ -839,10 +835,7 @@ load_recent_items (gpointer user_data)
/* we have finished loading, so we remove the items cache */ /* we have finished loading, so we remove the items cache */
impl->load_state = LOAD_LOADING; impl->load_state = LOAD_LOADING;
g_list_foreach (impl->recent_items, g_list_free_full (impl->recent_items, (GDestroyNotify) gtk_recent_info_unref);
(GFunc) gtk_recent_info_unref,
NULL);
g_list_free (impl->recent_items);
impl->recent_items = NULL; impl->recent_items = NULL;
impl->n_recent_items = 0; impl->n_recent_items = 0;

View File

@ -1055,8 +1055,7 @@ check_and_return:
if (pdata->loaded_items == pdata->n_items) if (pdata->loaded_items == pdata->n_items)
{ {
g_list_foreach (pdata->items, (GFunc) gtk_recent_info_unref, NULL); g_list_free_full (pdata->items, (GDestroyNotify) gtk_recent_info_unref);
g_list_free (pdata->items);
priv->populate_id = 0; priv->populate_id = 0;

View File

@ -525,8 +525,7 @@ _gtk_recent_chooser_get_items (GtkRecentChooser *chooser,
l = clamp->next; l = clamp->next;
clamp->next = NULL; clamp->next = NULL;
g_list_foreach (l, (GFunc) gtk_recent_info_unref, NULL); g_list_free_full (l, (GDestroyNotify) gtk_recent_info_unref);
g_list_free (l);
} }
return items; return items;

View File

@ -168,8 +168,7 @@ search_thread_add_hits_idle (gpointer user_data)
hits->uris); hits->uris);
} }
g_list_foreach (hits->uris, (GFunc)g_free, NULL); g_list_free_full (hits->uris, g_free);
g_list_free (hits->uris);
g_free (hits); g_free (hits);
return FALSE; return FALSE;

View File

@ -584,8 +584,7 @@ style_data_free (StyleData *data)
g_object_unref (data->store); g_object_unref (data->store);
clear_property_cache (data); clear_property_cache (data);
g_slist_foreach (data->icon_factories, (GFunc) g_object_unref, NULL); g_slist_free_full (data->icon_factories, g_object_unref);
g_slist_free (data->icon_factories);
g_slice_free (StyleData, data); g_slice_free (StyleData, data);
} }
@ -806,11 +805,9 @@ gtk_style_context_finalize (GObject *object)
g_hash_table_destroy (priv->style_data); g_hash_table_destroy (priv->style_data);
g_list_foreach (priv->providers, (GFunc) style_provider_data_free, NULL); g_list_free_full (priv->providers, (GDestroyNotify) style_provider_data_free);
g_list_free (priv->providers);
g_slist_foreach (priv->info_stack, (GFunc) style_info_free, NULL); g_slist_free_full (priv->info_stack, (GDestroyNotify) style_info_free);
g_slist_free (priv->info_stack);
g_slist_free (priv->animation_regions); g_slist_free (priv->animation_regions);

View File

@ -797,8 +797,7 @@ free_format (GtkRichTextFormat *format)
static void static void
free_format_list (GList *formats) free_format_list (GList *formats)
{ {
g_list_foreach (formats, (GFunc) free_format, NULL); g_list_free_full (formats, (GDestroyNotify) free_format);
g_list_free (formats);
} }
static GQuark static GQuark

View File

@ -1784,8 +1784,7 @@ read_headers (const gchar *start,
return g_list_reverse (headers); return g_list_reverse (headers);
error: error:
g_list_foreach (headers, (GFunc) g_free, NULL); g_list_free_full (headers, g_free);
g_list_free (headers);
g_set_error_literal (error, g_set_error_literal (error,
G_MARKUP_ERROR, G_MARKUP_ERROR,
@ -1879,8 +1878,7 @@ _gtk_text_buffer_deserialize_rich_text (GtkTextBuffer *register_buffer,
create_tags, error, headers->next); create_tags, error, headers->next);
out: out:
g_list_foreach (headers, (GFunc)g_free, NULL); g_list_free_full (headers, g_free);
g_list_free (headers);
return retval; return retval;
} }

View File

@ -10148,8 +10148,7 @@ gtk_tree_view_focus_to_cursor (GtkTreeView *tree_view)
if (selected_rows) if (selected_rows)
{ {
cursor_path = gtk_tree_path_copy((const GtkTreePath *)(selected_rows->data)); cursor_path = gtk_tree_path_copy((const GtkTreePath *)(selected_rows->data));
g_list_foreach (selected_rows, (GFunc)gtk_tree_path_free, NULL); g_list_free_full (selected_rows, (GDestroyNotify) gtk_tree_path_free);
g_list_free (selected_rows);
} }
else else
{ {

View File

@ -680,9 +680,7 @@ gtk_ui_manager_finalize (GObject *object)
g_node_destroy (manager->private_data->root_node); g_node_destroy (manager->private_data->root_node);
manager->private_data->root_node = NULL; manager->private_data->root_node = NULL;
g_list_foreach (manager->private_data->action_groups, g_list_free_full (manager->private_data->action_groups, g_object_unref);
(GFunc) g_object_unref, NULL);
g_list_free (manager->private_data->action_groups);
manager->private_data->action_groups = NULL; manager->private_data->action_groups = NULL;
g_object_unref (manager->private_data->accel_group); g_object_unref (manager->private_data->accel_group);
@ -1392,8 +1390,7 @@ free_node (GNode *node)
{ {
Node *info = NODE_INFO (node); Node *info = NODE_INFO (node);
g_list_foreach (info->uifiles, (GFunc) node_ui_reference_free, NULL); g_list_free_full (info->uifiles, node_ui_reference_free);
g_list_free (info->uifiles);
if (info->action) if (info->action)
g_object_unref (info->action); g_object_unref (info->action);

View File

@ -12030,8 +12030,7 @@ gtk_widget_buildable_parser_finished (GtkBuildable *buildable,
} }
g_object_unref (relation_set); g_object_unref (relation_set);
g_slist_foreach (atk_relations, (GFunc)free_relation, NULL); g_slist_free_full (atk_relations, (GDestroyNotify) free_relation);
g_slist_free (atk_relations);
g_object_set_qdata (G_OBJECT (buildable), quark_builder_atk_relations, g_object_set_qdata (G_OBJECT (buildable), quark_builder_atk_relations,
NULL); NULL);
} }
@ -12438,8 +12437,7 @@ gtk_widget_buildable_custom_finished (GtkBuildable *buildable,
else else
g_warning ("accessibility action on a widget that does not implement AtkAction"); g_warning ("accessibility action on a widget that does not implement AtkAction");
g_slist_foreach (a11y_data->actions, (GFunc)free_action, NULL); g_slist_free_full (a11y_data->actions, (GDestroyNotify) free_action);
g_slist_free (a11y_data->actions);
} }
if (a11y_data->relations) if (a11y_data->relations)

View File

@ -3482,8 +3482,7 @@ gtk_window_realize_icon (GtkWindow *window)
{ {
GtkIconTheme *icon_theme; GtkIconTheme *icon_theme;
g_list_foreach (icon_list, (GFunc) g_object_unref, NULL); g_list_free_full (icon_list, g_object_unref);
g_list_free (icon_list);
icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window))); icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window)));
g_signal_connect (icon_theme, "changed", g_signal_connect (icon_theme, "changed",
@ -3564,10 +3563,7 @@ gtk_window_set_icon_list (GtkWindow *window,
g_list_foreach (list, g_list_foreach (list,
(GFunc) g_object_ref, NULL); (GFunc) g_object_ref, NULL);
g_list_foreach (info->icon_list, g_list_free_full (info->icon_list, g_object_unref);
(GFunc) g_object_unref, NULL);
g_list_free (info->icon_list);
info->icon_list = g_list_copy (list); info->icon_list = g_list_copy (list);
@ -3695,8 +3691,7 @@ gtk_window_set_icon_name (GtkWindow *window,
info->icon_name = g_strdup (name); info->icon_name = g_strdup (name);
g_free (tmp); g_free (tmp);
g_list_foreach (info->icon_list, (GFunc) g_object_unref, NULL); g_list_free_full (info->icon_list, g_object_unref);
g_list_free (info->icon_list);
info->icon_list = NULL; info->icon_list = NULL;
update_themed_icon (NULL, window); update_themed_icon (NULL, window);
@ -3839,10 +3834,7 @@ gtk_window_set_default_icon_list (GList *list)
g_list_foreach (list, g_list_foreach (list,
(GFunc) g_object_ref, NULL); (GFunc) g_object_ref, NULL);
g_list_foreach (default_icon_list, g_list_free_full (default_icon_list, g_object_unref);
(GFunc) g_object_unref, NULL);
g_list_free (default_icon_list);
default_icon_list = g_list_copy (list); default_icon_list = g_list_copy (list);
@ -3911,10 +3903,7 @@ gtk_window_set_default_icon_name (const gchar *name)
g_free (default_icon_name); g_free (default_icon_name);
default_icon_name = g_strdup (name); default_icon_name = g_strdup (name);
g_list_foreach (default_icon_list, g_list_free_full (default_icon_list, g_object_unref);
(GFunc) g_object_unref, NULL);
g_list_free (default_icon_list);
default_icon_list = NULL; default_icon_list = NULL;
/* Update all toplevels */ /* Update all toplevels */

View File

@ -1525,8 +1525,7 @@ opentmp:
} }
cache = NULL; cache = NULL;
g_list_foreach (directories, (GFunc)g_free, NULL); g_list_free_full (directories, g_free);
g_list_free (directories);
if (!validate_file (tmp_cache_path)) if (!validate_file (tmp_cache_path))
{ {