[gtk+] placesview: plug some memory leaks
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] placesview: plug some memory leaks
- Date: Tue, 28 Jul 2015 10:03:39 +0000 (UTC)
commit 317ba620e21340286602ac4d40bee641f9c61903
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Jul 28 06:51:14 2015 -0300
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 b685b85..628376e 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 97ce9b6..89f2052 100644
--- a/gtk/gtkplacesviewrow.c
+++ b/gtk/gtkplacesviewrow.c
@@ -57,6 +57,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,
GValue *value,
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]