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_list_foreach (hierarchy, (GFunc) g_object_unref, NULL);
g_list_free (hierarchy);
g_list_free_full (hierarchy, g_object_unref);
if (found)
return TRUE;

View File

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

View File

@ -734,10 +734,8 @@ blow_themes (GtkIconTheme *icon_theme)
if (priv->themes_valid)
{
g_hash_table_destroy (priv->all_icons);
g_list_foreach (priv->themes, (GFunc)theme_destroy, NULL);
g_list_free (priv->themes);
g_list_foreach (priv->dir_mtimes, (GFunc)free_dir_mtime, NULL);
g_list_free (priv->dir_mtimes);
g_list_free_full (priv->themes, (GDestroyNotify) theme_destroy);
g_list_free_full (priv->dir_mtimes, (GDestroyNotify) free_dir_mtime);
g_hash_table_destroy (priv->unthemed_icons);
}
priv->themes = NULL;
@ -2021,8 +2019,7 @@ theme_destroy (IconTheme *theme)
g_free (theme->name);
g_free (theme->example);
g_list_foreach (theme->dirs, (GFunc)theme_dir_destroy, NULL);
g_list_free (theme->dirs);
g_list_free_full (theme->dirs, (GDestroyNotify) theme_dir_destroy);
g_free (theme);
}
@ -2721,8 +2718,7 @@ gtk_icon_info_free (GtkIconInfo *icon_info)
g_free (icon_info->filename);
if (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 (icon_info->emblem_infos);
g_slist_free_full (icon_info->emblem_infos, (GDestroyNotify) gtk_icon_info_free);
if (icon_info->pixbuf)
g_object_unref (icon_info->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_list_foreach (icon_view->priv->items, (GFunc)gtk_icon_view_item_free, NULL);
g_list_free (icon_view->priv->items);
g_list_free_full (icon_view->priv->items, (GDestroyNotify) gtk_icon_view_item_free);
icon_view->priv->items = NULL;
icon_view->priv->anchor_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:
* |[
* g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL);
* g_list_free (list);
* g_list_free_full (list, (GDestroyNotify) gtk_tree_patch_free);
* ]|
*
* 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:
g_markup_parse_context_free (context);
g_string_free (pdata.new_str, TRUE);
g_list_foreach (pdata.links, (GFunc)link_free, NULL);
g_list_free (pdata.links);
g_list_free_full (pdata.links, (GDestroyNotify) link_free);
gdk_color_free (pdata.link_color);
gdk_color_free (pdata.visited_link_color);
@ -6267,8 +6266,7 @@ gtk_label_clear_links (GtkLabel *label)
if (!priv->select_info)
return;
g_list_foreach (priv->select_info->links, (GFunc)link_free, NULL);
g_list_free (priv->select_info->links);
g_list_free_full (priv->select_info->links, (GDestroyNotify) link_free);
priv->select_info->links = 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));
}
g_list_foreach (page_setups, (GFunc) g_object_unref, NULL);
g_list_free (page_setups);
g_list_free_full (page_setups, g_object_unref);
}
#endif
for (i = 0; i < G_N_ELEMENTS (standard_names_offsets); ++i)

View File

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

View File

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

View File

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

View File

@ -629,12 +629,8 @@ gtk_recent_chooser_default_dispose (GObject *object)
impl->load_id = 0;
}
if (impl->recent_items)
{
g_list_foreach (impl->recent_items, (GFunc) gtk_recent_info_unref, NULL);
g_list_free (impl->recent_items);
impl->recent_items = NULL;
}
g_list_free_full (impl->recent_items, (GDestroyNotify) gtk_recent_info_unref);
impl->recent_items = NULL;
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 */
impl->load_state = LOAD_LOADING;
g_list_foreach (impl->recent_items,
(GFunc) gtk_recent_info_unref,
NULL);
g_list_free (impl->recent_items);
g_list_free_full (impl->recent_items, (GDestroyNotify) gtk_recent_info_unref);
impl->recent_items = NULL;
impl->n_recent_items = 0;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10148,8 +10148,7 @@ gtk_tree_view_focus_to_cursor (GtkTreeView *tree_view)
if (selected_rows)
{
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 (selected_rows);
g_list_free_full (selected_rows, (GDestroyNotify) gtk_tree_path_free);
}
else
{

View File

@ -680,9 +680,7 @@ gtk_ui_manager_finalize (GObject *object)
g_node_destroy (manager->private_data->root_node);
manager->private_data->root_node = NULL;
g_list_foreach (manager->private_data->action_groups,
(GFunc) g_object_unref, NULL);
g_list_free (manager->private_data->action_groups);
g_list_free_full (manager->private_data->action_groups, g_object_unref);
manager->private_data->action_groups = NULL;
g_object_unref (manager->private_data->accel_group);
@ -1392,8 +1390,7 @@ free_node (GNode *node)
{
Node *info = NODE_INFO (node);
g_list_foreach (info->uifiles, (GFunc) node_ui_reference_free, NULL);
g_list_free (info->uifiles);
g_list_free_full (info->uifiles, node_ui_reference_free);
if (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_slist_foreach (atk_relations, (GFunc)free_relation, NULL);
g_slist_free (atk_relations);
g_slist_free_full (atk_relations, (GDestroyNotify) free_relation);
g_object_set_qdata (G_OBJECT (buildable), quark_builder_atk_relations,
NULL);
}
@ -12438,8 +12437,7 @@ gtk_widget_buildable_custom_finished (GtkBuildable *buildable,
else
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 (a11y_data->actions);
g_slist_free_full (a11y_data->actions, (GDestroyNotify) free_action);
}
if (a11y_data->relations)

View File

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

View File

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