From 317ba620e21340286602ac4d40bee641f9c61903 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Tue, 28 Jul 2015 06:51:14 -0300 Subject: [PATCH] placesview: plug some memory leaks The GFile containing the Computer item was not properly dereferenced, so plug that leak by both dereferencing it and adding some reference management on GtkPlacesViewRow. --- gtk/gtkplacesview.c | 3 +++ gtk/gtkplacesviewrow.c | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gtk/gtkplacesview.c b/gtk/gtkplacesview.c index b685b855ee..628376ee5e 100644 --- a/gtk/gtkplacesview.c +++ b/gtk/gtkplacesview.c @@ -874,6 +874,9 @@ add_computer (GtkPlacesView *view) NULL); insert_row (view, row, FALSE); + + g_object_unref (icon); + g_object_unref (file); } static void diff --git a/gtk/gtkplacesviewrow.c b/gtk/gtkplacesviewrow.c index 97ce9b67c7..89f20527eb 100644 --- a/gtk/gtkplacesviewrow.c +++ b/gtk/gtkplacesviewrow.c @@ -56,6 +56,16 @@ enum { static GParamSpec *properties [LAST_PROP]; +static void +gtk_places_view_row_finalize (GObject *object) +{ + GtkPlacesViewRow *self = GTK_PLACES_VIEW_ROW (object); + + g_clear_object (&self->volume); + g_clear_object (&self->mount); + g_clear_object (&self->file); +} + static void gtk_places_view_row_get_property (GObject *object, guint prop_id, @@ -125,16 +135,16 @@ gtk_places_view_row_set_property (GObject *object, break; case PROP_VOLUME: - self->volume = g_value_get_object (value); + g_set_object (&self->volume, g_value_get_object (value)); break; case PROP_MOUNT: - self->mount = g_value_get_object (value); + g_set_object (&self->mount, g_value_get_object (value)); gtk_widget_set_visible (GTK_WIDGET (self->eject_button), self->mount != NULL); break; case PROP_FILE: - self->file = g_value_get_object (value); + g_set_object (&self->file, g_value_get_object (value)); break; default: @@ -148,6 +158,7 @@ gtk_places_view_row_class_init (GtkPlacesViewRowClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + object_class->finalize = gtk_places_view_row_finalize; object_class->get_property = gtk_places_view_row_get_property; object_class->set_property = gtk_places_view_row_set_property;