From 80de73f0b4d904e77164399811a5d7da7ecf47f3 Mon Sep 17 00:00:00 2001 From: Juan Pablo Ugarte Date: Mon, 17 Aug 2020 16:31:55 -0300 Subject: Use g_list_free_full() instead of g_list_foreach() + g_list_free() Also fix -Wcast-function-type warnings --- plugins/gtk+/glade-accels.c | 6 +++--- plugins/gtk+/glade-column-types.c | 3 +-- plugins/gtk+/glade-gtk-grid.c | 2 +- plugins/gtk+/glade-gtk-notebook.c | 5 ++--- plugins/gtk+/glade-gtk-table.c | 2 +- plugins/gtk+/glade-gtk-widget.c | 3 +-- plugins/gtk+/glade-icon-sources.c | 3 +-- plugins/gtk+/glade-string-list.c | 6 ++---- 8 files changed, 12 insertions(+), 18 deletions(-) (limited to 'plugins') diff --git a/plugins/gtk+/glade-accels.c b/plugins/gtk+/glade-accels.c index 994e846b..479c7980 100644 --- a/plugins/gtk+/glade-accels.c +++ b/plugins/gtk+/glade-accels.c @@ -187,8 +187,9 @@ eprop_find_iter (GladeEpropIterTab * iter_tab, gchar * name) } static void -iter_tab_free (GladeEpropIterTab * iter_tab) +iter_tab_free (gpointer data) { + GladeEpropIterTab *iter_tab = data; gtk_tree_iter_free (iter_tab->iter); g_free (iter_tab); } @@ -582,8 +583,7 @@ glade_eprop_accel_show_dialog (GladeEditorProperty *eprop) if (eprop_accel->parent_iters) { - g_list_foreach (eprop_accel->parent_iters, (GFunc) iter_tab_free, NULL); - g_list_free (eprop_accel->parent_iters); + g_list_free_full (eprop_accel->parent_iters, iter_tab_free); eprop_accel->parent_iters = NULL; } diff --git a/plugins/gtk+/glade-column-types.c b/plugins/gtk+/glade-column-types.c index 2f769211..80a50d04 100644 --- a/plugins/gtk+/glade-column-types.c +++ b/plugins/gtk+/glade-column-types.c @@ -186,8 +186,7 @@ glade_column_type_free (GladeColumnType * column) void glade_column_list_free (GList * list) { - g_list_foreach (list, (GFunc) glade_column_type_free, NULL); - g_list_free (list); + g_list_free_full (list, (GDestroyNotify) glade_column_type_free); } GladeColumnType * diff --git a/plugins/gtk+/glade-gtk-grid.c b/plugins/gtk+/glade-gtk-grid.c index a851b2e7..27f069d9 100644 --- a/plugins/gtk+/glade-gtk-grid.c +++ b/plugins/gtk+/glade-gtk-grid.c @@ -530,7 +530,7 @@ glade_gtk_grid_child_insert_remove_action (GladeWidgetAdaptor *adaptor, children = glade_widget_adaptor_get_children (adaptor, container); /* Make sure widgets does not get destroyed */ - glade_util_object_list_ref (children); + glade_util_list_objects_ref (children); glade_widget_property_get (parent, n_row_col, &size); diff --git a/plugins/gtk+/glade-gtk-notebook.c b/plugins/gtk+/glade-gtk-notebook.c index 8847e5da..5d5170dc 100644 --- a/plugins/gtk+/glade-gtk-notebook.c +++ b/plugins/gtk+/glade-gtk-notebook.c @@ -1005,7 +1005,7 @@ glade_gtk_box_notebook_child_insert_remove_action (GladeWidgetAdaptor *adaptor, /* Make sure widgets does not get destroyed */ children = glade_widget_adaptor_get_children (adaptor, container); - glade_util_object_list_ref (children); + glade_util_list_objects_ref (children); glade_widget_property_get (parent, size_prop, &size); @@ -1085,7 +1085,6 @@ glade_gtk_box_notebook_child_insert_remove_action (GladeWidgetAdaptor *adaptor, glade_widget_get_project (parent)); } - g_list_foreach (children, (GFunc) g_object_unref, NULL); - g_list_free (children); + g_list_free_full (children, g_object_unref); glade_command_pop_group (); } diff --git a/plugins/gtk+/glade-gtk-table.c b/plugins/gtk+/glade-gtk-table.c index 2c67f338..1e51f790 100644 --- a/plugins/gtk+/glade-gtk-table.c +++ b/plugins/gtk+/glade-gtk-table.c @@ -563,7 +563,7 @@ glade_gtk_table_child_insert_remove_action (GladeWidgetAdaptor *adaptor, children = glade_widget_adaptor_get_children (adaptor, container); /* Make sure widgets does not get destroyed */ - glade_util_object_list_ref (children); + glade_util_list_objects_ref (children); glade_widget_property_get (parent, n_row_col, &size); diff --git a/plugins/gtk+/glade-gtk-widget.c b/plugins/gtk+/glade-gtk-widget.c index 5bf06423..6061d8b9 100644 --- a/plugins/gtk+/glade-gtk-widget.c +++ b/plugins/gtk+/glade-gtk-widget.c @@ -978,8 +978,7 @@ glade_gtk_widget_action_activate (GladeWidgetAdaptor *adaptor, glade_project_undo (project); } - g_list_foreach (saved_props, (GFunc) g_object_unref, NULL); - g_list_free (saved_props); + g_list_free_full (saved_props, g_object_unref); } } else if (strcmp (action_path, "sizegroup_add") == 0) diff --git a/plugins/gtk+/glade-icon-sources.c b/plugins/gtk+/glade-icon-sources.c index 3ed25b83..c2bb57c9 100644 --- a/plugins/gtk+/glade-icon-sources.c +++ b/plugins/gtk+/glade-icon-sources.c @@ -49,9 +49,8 @@ static void icon_set_free (GList *list) { G_GNUC_BEGIN_IGNORE_DEPRECATIONS - g_list_foreach (list, (GFunc) gtk_icon_source_free, NULL); + g_list_free_full (list, (GDestroyNotify) gtk_icon_source_free); G_GNUC_END_IGNORE_DEPRECATIONS - g_list_free (list); } diff --git a/plugins/gtk+/glade-string-list.c b/plugins/gtk+/glade-string-list.c index 2dd2e1c5..f9d2551f 100644 --- a/plugins/gtk+/glade-string-list.c +++ b/plugins/gtk+/glade-string-list.c @@ -109,8 +109,7 @@ glade_string_list_copy (GList *string_list) void glade_string_list_free (GList *string_list) { - g_list_foreach (string_list, (GFunc)glade_string_free, NULL); - g_list_free (string_list); + g_list_free_full (string_list, (GDestroyNotify) glade_string_free); } GType @@ -632,8 +631,7 @@ treeview_key_press (GtkWidget *treeview, gtk_list_store_remove (GTK_LIST_STORE (eprop_string_list->model), &iter); } - 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); } return TRUE; } -- cgit v1.2.1