[devhelp/wip/stuff: 7/13] sidebar: improve disposing



commit 1c11d68e68fae9d241cc2c34cc76990aaa3a9a53
Author: Ignacio Casal Quinteiro <ignacio casal nice-software com>
Date:   Thu Jul 25 10:36:27 2013 +0200

    sidebar: improve disposing

 src/dh-sidebar.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/src/dh-sidebar.c b/src/dh-sidebar.c
index 2b1ec5c..1b10c41 100644
--- a/src/dh-sidebar.c
+++ b/src/dh-sidebar.c
@@ -430,17 +430,26 @@ dh_sidebar_new (DhBookManager *book_manager)
 }
 
 static void
-sidebar_finalize (GObject *object)
+dh_sidebar_finalize (GObject *object)
 {
         DhSidebar *self = DH_SIDEBAR (object);
 
         g_completion_free (self->priv->completion);
-        g_object_unref (self->priv->book_manager);
 
         G_OBJECT_CLASS (dh_sidebar_parent_class)->finalize (object);
 }
 
 static void
+dh_sidebar_dispose (GObject *object)
+{
+        DhSidebarPrivate *priv = DH_SIDEBAR (object)->priv;
+
+        g_clear_object (&priv->book_manager);
+
+        G_OBJECT_CLASS (dh_sidebar_parent_class)->dispose (object);
+}
+
+static void
 dh_sidebar_init (DhSidebar *self)
 {
         GtkCellRenderer  *cell;
@@ -627,7 +636,8 @@ dh_sidebar_class_init (DhSidebarClass *klass)
 {
         GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-        object_class->finalize = sidebar_finalize;
+        object_class->finalize = dh_sidebar_finalize;
+        object_class->dispose = dh_sidebar_dispose;
         object_class->get_property = dh_sidebar_get_property;
         object_class->set_property = dh_sidebar_set_property;
         object_class->constructed = dh_sidebar_constructed;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]