app: use g_clear_pointer() in more places

This commit is contained in:
Michael Natterer 2019-05-27 17:47:55 +02:00
parent 9fa49af470
commit 901350ba20
35 changed files with 124 additions and 320 deletions

View File

@ -149,11 +149,8 @@ gimp_lang_rc_finalize (GObject *object)
g_clear_object (&rc->system_gimprc); g_clear_object (&rc->system_gimprc);
g_clear_object (&rc->user_gimprc); g_clear_object (&rc->user_gimprc);
if (rc->language)
{ g_clear_pointer (&rc->language, g_free);
g_free (rc->language);
rc->language = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }

View File

@ -121,8 +121,7 @@ gimp_brush_pipe_finalize (GObject *object)
if (pipe->brushes[i]) if (pipe->brushes[i])
g_object_unref (pipe->brushes[i]); g_object_unref (pipe->brushes[i]);
g_free (pipe->brushes); g_clear_pointer (&pipe->brushes, g_free);
pipe->brushes = NULL;
} }
GIMP_BRUSH (pipe)->priv->mask = NULL; GIMP_BRUSH (pipe)->priv->mask = NULL;

View File

@ -350,17 +350,8 @@ gimp_channel_finalize (GObject *object)
{ {
GimpChannel *channel = GIMP_CHANNEL (object); GimpChannel *channel = GIMP_CHANNEL (object);
if (channel->segs_in) g_clear_pointer (&channel->segs_in, g_free);
{ g_clear_pointer (&channel->segs_out, g_free);
g_free (channel->segs_in);
channel->segs_in = NULL;
}
if (channel->segs_out)
{
g_free (channel->segs_out);
channel->segs_out = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
@ -1166,14 +1157,10 @@ gimp_channel_real_is_empty (GimpChannel *channel)
return FALSE; return FALSE;
/* The mask is empty, meaning we can set the bounds as known */ /* The mask is empty, meaning we can set the bounds as known */
if (channel->segs_in) g_clear_pointer (&channel->segs_in, g_free);
g_free (channel->segs_in); g_clear_pointer (&channel->segs_out, g_free);
if (channel->segs_out)
g_free (channel->segs_out);
channel->empty = TRUE; channel->empty = TRUE;
channel->segs_in = NULL;
channel->segs_out = NULL;
channel->num_segs_in = 0; channel->num_segs_in = 0;
channel->num_segs_out = 0; channel->num_segs_out = 0;
channel->bounds_known = TRUE; channel->bounds_known = TRUE;

View File

@ -224,17 +224,11 @@ gimp_curve_finalize (GObject *object)
{ {
GimpCurve *curve = GIMP_CURVE (object); GimpCurve *curve = GIMP_CURVE (object);
if (curve->points) g_clear_pointer (&curve->points, g_free);
{ curve->n_points = 0;
g_free (curve->points);
curve->points = NULL;
}
if (curve->samples) g_clear_pointer (&curve->samples, g_free);
{ curve->n_samples = 0;
g_free (curve->samples);
curve->samples = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
@ -1043,8 +1037,8 @@ gimp_curve_clear_points (GimpCurve *curve)
if (curve->points) if (curve->points)
{ {
curve->n_points = 0;
g_clear_pointer (&curve->points, g_free); g_clear_pointer (&curve->points, g_free);
curve->n_points = 0;
g_object_notify (G_OBJECT (curve), "n-points"); g_object_notify (G_OBJECT (curve), "n-points");
g_object_notify (G_OBJECT (curve), "points"); g_object_notify (G_OBJECT (curve), "points");

View File

@ -370,8 +370,7 @@ gimp_histogram_clear_values (GimpHistogram *histogram)
if (histogram->priv->values) if (histogram->priv->values)
{ {
g_free (histogram->priv->values); g_clear_pointer (&histogram->priv->values, g_free);
histogram->priv->values = NULL;
g_object_notify (G_OBJECT (histogram), "values"); g_object_notify (G_OBJECT (histogram), "values");
} }

View File

@ -2507,8 +2507,7 @@ gimp_layer_set_floating_sel_drawable (GimpLayer *layer,
{ {
if (layer->fs.segs) if (layer->fs.segs)
{ {
g_free (layer->fs.segs); g_clear_pointer (&layer->fs.segs, g_free);
layer->fs.segs = NULL;
layer->fs.num_segs = 0; layer->fs.num_segs = 0;
} }

View File

@ -109,11 +109,7 @@ gimp_mybrush_finalize (GObject *object)
{ {
GimpMybrush *brush = GIMP_MYBRUSH (object); GimpMybrush *brush = GIMP_MYBRUSH (object);
if (brush->priv->brush_json) g_clear_pointer (&brush->priv->brush_json, g_free);
{
g_free (brush->priv->brush_json);
brush->priv->brush_json = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }

View File

@ -1254,8 +1254,7 @@ gimp_viewable_set_icon_name (GimpViewable *viewable,
private = GET_PRIVATE (viewable); private = GET_PRIVATE (viewable);
g_free (private->icon_name); g_clear_pointer (&private->icon_name, g_free);
private->icon_name = NULL;
viewable_class = GIMP_VIEWABLE_GET_CLASS (viewable); viewable_class = GIMP_VIEWABLE_GET_CLASS (viewable);

View File

@ -130,18 +130,10 @@ gimp_canvas_boundary_finalize (GObject *object)
{ {
GimpCanvasBoundaryPrivate *private = GET_PRIVATE (object); GimpCanvasBoundaryPrivate *private = GET_PRIVATE (object);
if (private->segs) g_clear_pointer (&private->segs, g_free);
{ private->n_segs = 0;
g_free (private->segs);
private->segs = NULL;
private->n_segs = 0;
}
if (private->transform) g_clear_pointer (&private->transform, g_free);
{
g_free (private->transform);
private->transform = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }

View File

@ -121,18 +121,10 @@ gimp_canvas_polygon_finalize (GObject *object)
{ {
GimpCanvasPolygonPrivate *private = GET_PRIVATE (object); GimpCanvasPolygonPrivate *private = GET_PRIVATE (object);
if (private->points) g_clear_pointer (&private->points, g_free);
{ private->n_points = 0;
g_free (private->points);
private->points = NULL;
private->n_points = 0;
}
if (private->transform) g_clear_pointer (&private->transform, g_free);
{
g_free (private->transform);
private->transform = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
@ -151,8 +143,7 @@ gimp_canvas_polygon_set_property (GObject *object,
{ {
GimpArray *array = g_value_get_boxed (value); GimpArray *array = g_value_get_boxed (value);
g_free (private->points); g_clear_pointer (&private->points, g_free);
private->points = NULL;
private->n_points = 0; private->n_points = 0;
if (array) if (array)

View File

@ -173,11 +173,7 @@ gimp_canvas_progress_finalize (GObject *object)
{ {
GimpCanvasProgressPrivate *private = GET_PRIVATE (object); GimpCanvasProgressPrivate *private = GET_PRIVATE (object);
if (private->text) g_clear_pointer (&private->text, g_free);
{
g_free (private->text);
private->text = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }

View File

@ -819,11 +819,7 @@ gimp_tool_rectangle_finalize (GObject *object)
GimpToolRectangle *rectangle = GIMP_TOOL_RECTANGLE (object); GimpToolRectangle *rectangle = GIMP_TOOL_RECTANGLE (object);
GimpToolRectanglePrivate *private = rectangle->private; GimpToolRectanglePrivate *private = rectangle->private;
if (private->status_title) g_clear_pointer (&private->status_title, g_free);
{
g_free (private->status_title);
private->status_title = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }

View File

@ -120,8 +120,7 @@ gimp_procedure_finalize (GObject *object)
for (i = 0; i < procedure->num_args; i++) for (i = 0; i < procedure->num_args; i++)
g_param_spec_unref (procedure->args[i]); g_param_spec_unref (procedure->args[i]);
g_free (procedure->args); g_clear_pointer (&procedure->args, g_free);
procedure->args = NULL;
} }
if (procedure->values) if (procedure->values)
@ -129,8 +128,7 @@ gimp_procedure_finalize (GObject *object)
for (i = 0; i < procedure->num_values; i++) for (i = 0; i < procedure->num_values; i++)
g_param_spec_unref (procedure->values[i]); g_param_spec_unref (procedure->values[i]);
g_free (procedure->values); g_clear_pointer (&procedure->values, g_free);
procedure->values = NULL;
} }
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);

View File

@ -318,26 +318,10 @@ gimp_text_finalize (GObject *object)
{ {
GimpText *text = GIMP_TEXT (object); GimpText *text = GIMP_TEXT (object);
if (text->text) g_clear_pointer (&text->text, g_free);
{ g_clear_pointer (&text->markup, g_free);
g_free (text->text); g_clear_pointer (&text->font, g_free);
text->text = NULL; g_clear_pointer (&text->language, g_free);
}
if (text->markup)
{
g_free (text->markup);
text->markup = NULL;
}
if (text->font)
{
g_free (text->font);
text->font = NULL;
}
if (text->language)
{
g_free (text->language);
text->language = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
@ -448,8 +432,7 @@ gimp_text_set_property (GObject *object,
text->text = g_value_dup_string (value); text->text = g_value_dup_string (value);
if (text->text && text->markup) if (text->text && text->markup)
{ {
g_free (text->markup); g_clear_pointer (&text->markup, g_free);
text->markup = NULL;
g_object_notify (object, "markup"); g_object_notify (object, "markup");
} }
break; break;
@ -458,8 +441,7 @@ gimp_text_set_property (GObject *object,
text->markup = g_value_dup_string (value); text->markup = g_value_dup_string (value);
if (text->markup && text->text) if (text->markup && text->text)
{ {
g_free (text->text); g_clear_pointer (&text->text, g_free);
text->text = NULL;
g_object_notify (object, "text"); g_object_notify (object, "text");
} }
break; break;

View File

@ -186,31 +186,14 @@ gimp_edit_selection_tool_finalize (GObject *object)
{ {
GimpEditSelectionTool *edit_select = GIMP_EDIT_SELECTION_TOOL (object); GimpEditSelectionTool *edit_select = GIMP_EDIT_SELECTION_TOOL (object);
if (edit_select->segs_in) g_clear_pointer (&edit_select->segs_in, g_free);
{ edit_select->num_segs_in = 0;
g_free (edit_select->segs_in);
edit_select->segs_in = NULL;
edit_select->num_segs_in = 0;
}
if (edit_select->segs_out) g_clear_pointer (&edit_select->segs_out, g_free);
{ edit_select->num_segs_out = 0;
g_free (edit_select->segs_out);
edit_select->segs_out = NULL;
edit_select->num_segs_out = 0;
}
if (edit_select->live_items) g_clear_pointer (&edit_select->live_items, g_list_free);
{ g_clear_pointer (&edit_select->delayed_items, g_list_free);
g_list_free (edit_select->live_items);
edit_select->live_items = NULL;
}
if (edit_select->delayed_items)
{
g_list_free (edit_select->delayed_items);
edit_select->delayed_items = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }

View File

@ -245,11 +245,7 @@ gimp_text_options_finalize (GObject *object)
{ {
GimpTextOptions *options = GIMP_TEXT_OPTIONS (object); GimpTextOptions *options = GIMP_TEXT_OPTIONS (object);
if (options->language) g_clear_pointer (&options->language, g_free);
{
g_free (options->language);
options->language = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }

View File

@ -1711,8 +1711,7 @@ gimp_text_tool_im_delete_preedit (GimpTextTool *text_tool)
text_tool->preedit_end = NULL; text_tool->preedit_end = NULL;
} }
g_free (text_tool->preedit_string); g_clear_pointer (&text_tool->preedit_string, g_free);
text_tool->preedit_string = NULL;
} }
} }

View File

@ -190,17 +190,8 @@ gimp_action_group_finalize (GObject *object)
{ {
GimpActionGroup *group = GIMP_ACTION_GROUP (object); GimpActionGroup *group = GIMP_ACTION_GROUP (object);
if (group->label) g_clear_pointer (&group->label, g_free);
{ g_clear_pointer (&group->icon_name, g_free);
g_free (group->label);
group->label = NULL;
}
if (group->icon_name)
{
g_free (group->icon_name);
group->icon_name = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }

View File

@ -356,8 +356,7 @@ gimp_action_view_set_filter (GimpActionView *view,
if (filter && ! strlen (filter)) if (filter && ! strlen (filter))
filter = NULL; filter = NULL;
g_free (view->filter); g_clear_pointer (&view->filter, g_free);
view->filter = NULL;
if (filter) if (filter)
view->filter = g_utf8_casefold (filter, -1); view->filter = g_utf8_casefold (filter, -1);

View File

@ -191,10 +191,9 @@ gimp_color_history_finalize (GObject *object)
g_signal_handlers_disconnect_by_func (history->active_image, g_signal_handlers_disconnect_by_func (history->active_image,
G_CALLBACK (gimp_color_history_palette_dirty), G_CALLBACK (gimp_color_history_palette_dirty),
history); history);
g_free (history->color_areas);
history->color_areas = NULL; g_clear_pointer (&history->color_areas, g_free);
g_free (history->buttons); g_clear_pointer (&history->buttons, g_free);
history->buttons = NULL;
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
@ -214,6 +213,7 @@ gimp_color_history_set_property (GObject *object,
g_signal_handlers_disconnect_by_func (history->context, g_signal_handlers_disconnect_by_func (history->context,
gimp_color_history_image_changed, gimp_color_history_image_changed,
history); history);
if (history->active_image) if (history->active_image)
{ {
g_signal_handlers_disconnect_by_func (history->active_image, g_signal_handlers_disconnect_by_func (history->active_image,
@ -221,13 +221,17 @@ gimp_color_history_set_property (GObject *object,
history); history);
history->active_image = NULL; history->active_image = NULL;
} }
history->context = g_value_get_object (value); history->context = g_value_get_object (value);
if (history->context) if (history->context)
{ {
g_signal_connect (history->context, "image-changed", g_signal_connect (history->context, "image-changed",
G_CALLBACK (gimp_color_history_image_changed), G_CALLBACK (gimp_color_history_image_changed),
history); history);
history->active_image = gimp_context_get_image (history->context); history->active_image = gimp_context_get_image (history->context);
if (history->active_image) if (history->active_image)
{ {
g_signal_connect_swapped (history->active_image, "notify::base-type", g_signal_connect_swapped (history->active_image, "notify::base-type",
@ -241,56 +245,57 @@ gimp_color_history_set_property (GObject *object,
break; break;
case PROP_HISTORY_SIZE: case PROP_HISTORY_SIZE:
{ {
GtkWidget *button; GtkWidget *button;
GtkWidget *color_area; GtkWidget *color_area;
gint i; gint i;
history->history_size = g_value_get_int (value); history->history_size = g_value_get_int (value);
/* Destroy previous color buttons. */ /* Destroy previous color buttons. */
gtk_container_foreach (GTK_CONTAINER (history), gtk_container_foreach (GTK_CONTAINER (history),
(GtkCallback) gtk_widget_destroy, NULL); (GtkCallback) gtk_widget_destroy, NULL);
history->buttons = g_realloc_n (history->buttons, history->buttons = g_realloc_n (history->buttons,
history->history_size, history->history_size,
sizeof (GtkWidget*)); sizeof (GtkWidget*));
history->color_areas = g_realloc_n (history->color_areas, history->color_areas = g_realloc_n (history->color_areas,
history->history_size, history->history_size,
sizeof (GtkWidget*)); sizeof (GtkWidget*));
for (i = 0; i < history->history_size; i++)
{
GimpRGB black = { 0.0, 0.0, 0.0, 1.0 };
gint row, column;
column = i % (history->history_size / history->n_rows); for (i = 0; i < history->history_size; i++)
row = i / (history->history_size / history->n_rows); {
GimpRGB black = { 0.0, 0.0, 0.0, 1.0 };
gint row, column;
button = gtk_button_new (); column = i % (history->history_size / history->n_rows);
gtk_widget_set_size_request (button, COLOR_AREA_SIZE, COLOR_AREA_SIZE); row = i / (history->history_size / history->n_rows);
gtk_grid_attach (GTK_GRID (history), button, column, row, 1, 1);
gtk_widget_show (button);
color_area = gimp_color_area_new (&black, GIMP_COLOR_AREA_SMALL_CHECKS, button = gtk_button_new ();
GDK_BUTTON2_MASK); gtk_widget_set_size_request (button, COLOR_AREA_SIZE, COLOR_AREA_SIZE);
gimp_color_area_set_color_config (GIMP_COLOR_AREA (color_area), gtk_grid_attach (GTK_GRID (history), button, column, row, 1, 1);
history->context->gimp->config->color_management); gtk_widget_show (button);
gtk_container_add (GTK_CONTAINER (button), color_area);
gtk_widget_show (color_area);
g_signal_connect (button, "clicked", color_area = gimp_color_area_new (&black, GIMP_COLOR_AREA_SMALL_CHECKS,
G_CALLBACK (gimp_color_history_color_clicked), GDK_BUTTON2_MASK);
history); gimp_color_area_set_color_config (GIMP_COLOR_AREA (color_area),
history->context->gimp->config->color_management);
gtk_container_add (GTK_CONTAINER (button), color_area);
gtk_widget_show (color_area);
g_signal_connect (color_area, "color-changed", g_signal_connect (button, "clicked",
G_CALLBACK (gimp_color_history_color_changed), G_CALLBACK (gimp_color_history_color_clicked),
GINT_TO_POINTER (i)); history);
history->buttons[i] = button; g_signal_connect (color_area, "color-changed",
history->color_areas[i] = color_area; G_CALLBACK (gimp_color_history_color_changed),
} GINT_TO_POINTER (i));
gimp_color_history_palette_dirty (history); history->buttons[i] = button;
} history->color_areas[i] = color_area;
}
gimp_color_history_palette_dirty (history);
}
break; break;
default: default:

View File

@ -163,31 +163,10 @@ gimp_dockable_dispose (GObject *object)
if (dockable->p->context) if (dockable->p->context)
gimp_dockable_set_context (dockable, NULL); gimp_dockable_set_context (dockable, NULL);
if (dockable->p->blurb) g_clear_pointer (&dockable->p->blurb, g_free);
{ g_clear_pointer (&dockable->p->name, g_free);
if (dockable->p->blurb != dockable->p->name) g_clear_pointer (&dockable->p->icon_name, g_free);
g_free (dockable->p->blurb); g_clear_pointer (&dockable->p->help_id, g_free);
dockable->p->blurb = NULL;
}
if (dockable->p->name)
{
g_free (dockable->p->name);
dockable->p->name = NULL;
}
if (dockable->p->icon_name)
{
g_free (dockable->p->icon_name);
dockable->p->icon_name = NULL;
}
if (dockable->p->help_id)
{
g_free (dockable->p->help_id);
dockable->p->help_id = NULL;
}
G_OBJECT_CLASS (parent_class)->dispose (object); G_OBJECT_CLASS (parent_class)->dispose (object);
} }
@ -382,7 +361,7 @@ gimp_dockable_new (const gchar *name,
if (blurb) if (blurb)
dockable->p->blurb = g_strdup (blurb); dockable->p->blurb = g_strdup (blurb);
else else
dockable->p->blurb = dockable->p->name; dockable->p->blurb = g_strdup (dockable->p->name);
gimp_help_set_help_data (GTK_WIDGET (dockable), NULL, help_id); gimp_help_set_help_data (GTK_WIDGET (dockable), NULL, help_id);

View File

@ -378,25 +378,11 @@ gimp_file_dialog_dispose (GObject *object)
dialog->progress = NULL; dialog->progress = NULL;
if (dialog->help_id) g_clear_pointer (&dialog->help_id, g_free);
g_free (dialog->help_id); g_clear_pointer (&dialog->ok_button_label, g_free);
dialog->help_id = NULL; g_clear_pointer (&dialog->automatic_help_id, g_free);
g_clear_pointer (&dialog->automatic_label, g_free);
if (dialog->ok_button_label) g_clear_pointer (&dialog->file_filter_label, g_free);
g_free (dialog->ok_button_label);
dialog->ok_button_label = NULL;
if (dialog->automatic_help_id)
g_free (dialog->automatic_help_id);
dialog->automatic_help_id = NULL;
if (dialog->automatic_label)
g_free (dialog->automatic_label);
dialog->automatic_label = NULL;
if (dialog->file_filter_label)
g_free (dialog->file_filter_label);
dialog->file_filter_label = NULL;
} }
static gboolean static gboolean

View File

@ -143,12 +143,7 @@ gimp_image_parasite_view_finalize (GObject *object)
{ {
GimpImageParasiteView *view = GIMP_IMAGE_PARASITE_VIEW (object); GimpImageParasiteView *view = GIMP_IMAGE_PARASITE_VIEW (object);
if (view->parasite) g_clear_pointer (&view->parasite, g_free);
{
g_free (view->parasite);
view->parasite = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }

View File

@ -226,11 +226,7 @@ gimp_language_entry_set_code (GimpLanguageEntry *entry,
g_return_val_if_fail (GIMP_IS_LANGUAGE_ENTRY (entry), FALSE); g_return_val_if_fail (GIMP_IS_LANGUAGE_ENTRY (entry), FALSE);
if (entry->code) g_clear_pointer (&entry->code, g_free);
{
g_free (entry->code);
entry->code = NULL;
}
if (! code || ! strlen (code)) if (! code || ! strlen (code))
{ {

View File

@ -208,15 +208,13 @@ gimp_message_box_finalize (GObject *object)
GimpMessageBox *box = GIMP_MESSAGE_BOX (object); GimpMessageBox *box = GIMP_MESSAGE_BOX (object);
if (box->idle_id) if (box->idle_id)
g_source_remove (box->idle_id);
box->idle_id = 0;
if (box->icon_name)
{ {
g_free (box->icon_name); g_source_remove (box->idle_id);
box->icon_name = NULL; box->idle_id = 0;
} }
g_clear_pointer (&box->icon_name, g_free);
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }

View File

@ -286,17 +286,8 @@ gimp_overlay_dialog_finalize (GObject *object)
{ {
GimpOverlayDialog *dialog = GIMP_OVERLAY_DIALOG (object); GimpOverlayDialog *dialog = GIMP_OVERLAY_DIALOG (object);
if (dialog->title) g_clear_pointer (&dialog->title, g_free);
{ g_clear_pointer (&dialog->icon_name, g_free);
g_free (dialog->title);
dialog->title = NULL;
}
if (dialog->icon_name)
{
g_free (dialog->icon_name);
dialog->icon_name = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }

View File

@ -756,8 +756,7 @@ gimp_search_popup_find_accel_label (GtkAction *action)
/* The value returned by gtk_accelerator_get_label() must be /* The value returned by gtk_accelerator_get_label() must be
* freed after use. * freed after use.
*/ */
g_free (accel_string); g_clear_pointer (&accel_string, g_free);
accel_string = NULL;
} }
return accel_string; return accel_string;

View File

@ -88,11 +88,7 @@ gimp_session_info_dock_free (GimpSessionInfoDock *dock_info)
{ {
g_return_if_fail (dock_info != NULL); g_return_if_fail (dock_info != NULL);
if (dock_info->dock_type) g_clear_pointer (&dock_info->dock_type, g_free);
{
g_free (dock_info->dock_type);
dock_info->dock_type = NULL;
}
if (dock_info->books) if (dock_info->books)
{ {

View File

@ -59,11 +59,7 @@ gimp_session_info_dockable_free (GimpSessionInfoDockable *info)
{ {
g_return_if_fail (info != NULL); g_return_if_fail (info != NULL);
if (info->identifier) g_clear_pointer (&info->identifier, g_free);
{
g_free (info->identifier);
info->identifier = NULL;
}
if (info->aux_info) if (info->aux_info)
{ {

View File

@ -102,11 +102,7 @@ gimp_string_action_finalize (GObject *object)
{ {
GimpStringAction *action = GIMP_STRING_ACTION (object); GimpStringAction *action = GIMP_STRING_ACTION (object);
if (action->value) g_clear_pointer (&action->value, g_free);
{
g_free (action->value);
action->value = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }

View File

@ -220,11 +220,7 @@ gimp_tag_entry_dispose (GObject *object)
{ {
GimpTagEntry *entry = GIMP_TAG_ENTRY (object); GimpTagEntry *entry = GIMP_TAG_ENTRY (object);
if (entry->selected_items) g_clear_pointer (&entry->selected_items, g_list_free);
{
g_list_free (entry->selected_items);
entry->selected_items = NULL;
}
if (entry->common_tags) if (entry->common_tags)
{ {

View File

@ -391,8 +391,7 @@ gimp_tag_popup_dispose (GObject *object)
g_object_unref (popup->tag_data[i].tag); g_object_unref (popup->tag_data[i].tag);
} }
g_free (popup->tag_data); g_clear_pointer (&popup->tag_data, g_free);
popup->tag_data = NULL;
} }
G_OBJECT_CLASS (parent_class)->dispose (object); G_OBJECT_CLASS (parent_class)->dispose (object);

View File

@ -186,8 +186,7 @@ gimp_tool_editor_finalize (GObject *object)
g_free (priv->initial_tool_order[i]); g_free (priv->initial_tool_order[i]);
} }
g_free (priv->initial_tool_order); g_clear_pointer (&priv->initial_tool_order, g_free);
priv->initial_tool_order = NULL;
} }
if (priv->initial_tool_visibility) if (priv->initial_tool_visibility)

View File

@ -263,14 +263,8 @@ gimp_ui_manager_finalize (GObject *object)
g_slice_free (GimpUIManagerUIEntry, entry); g_slice_free (GimpUIManagerUIEntry, entry);
} }
g_list_free (manager->registered_uis); g_clear_pointer (&manager->registered_uis, g_list_free);
manager->registered_uis = NULL; g_clear_pointer (&manager->name, g_free);
if (manager->name)
{
g_free (manager->name);
manager->name = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }

View File

@ -116,23 +116,9 @@ gimp_viewable_button_finalize (GObject *object)
{ {
GimpViewableButton *button = GIMP_VIEWABLE_BUTTON (object); GimpViewableButton *button = GIMP_VIEWABLE_BUTTON (object);
if (button->dialog_identifier) g_clear_pointer (&button->dialog_identifier, g_free);
{ g_clear_pointer (&button->dialog_icon_name, g_free);
g_free (button->dialog_identifier); g_clear_pointer (&button->dialog_tooltip, g_free);
button->dialog_identifier = NULL;
}
if (button->dialog_icon_name)
{
g_free (button->dialog_icon_name);
button->dialog_icon_name = NULL;
}
if (button->dialog_tooltip)
{
g_free (button->dialog_tooltip);
button->dialog_tooltip = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }