[devhelp] book-manager: unref objects in dispose()



commit 0d9de63d09145bbbc8f7849480a32e1e613abd0b
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat May 23 19:55:05 2015 +0200

    book-manager: unref objects in dispose()
    
    Not in finalize().

 src/dh-book-manager.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/src/dh-book-manager.c b/src/dh-book-manager.c
index 032c91e..353e7c7 100644
--- a/src/dh-book-manager.c
+++ b/src/dh-book-manager.c
@@ -91,24 +91,36 @@ static void    dh_book_manager_set_property   (GObject        *object,
                                                GParamSpec     *pspec);
 
 static void
-dh_book_manager_finalize (GObject *object)
+dh_book_manager_dispose (GObject *object)
 {
         DhBookManagerPrivate *priv;
 
         priv = dh_book_manager_get_instance_private (DH_BOOK_MANAGER (object));
 
         g_list_free_full (priv->books, g_object_unref);
-        g_list_free_full (priv->languages, (GDestroyNotify)dh_language_free);
+        priv->books = NULL;
 
-        /* Destroy the monitors HT */
-        if (priv->monitors) {
+        if (priv->monitors != NULL) {
                 g_hash_table_destroy (priv->monitors);
+                priv->monitors = NULL;
         }
 
-        g_slist_free_full (priv->books_disabled, g_free);
-
         g_clear_object (&priv->settings);
 
+        G_OBJECT_CLASS (dh_book_manager_parent_class)->dispose (object);
+}
+
+static void
+dh_book_manager_finalize (GObject *object)
+{
+        DhBookManagerPrivate *priv;
+
+        priv = dh_book_manager_get_instance_private (DH_BOOK_MANAGER (object));
+
+        g_list_free_full (priv->languages, (GDestroyNotify)dh_language_free);
+
+        g_slist_free_full (priv->books_disabled, g_free);
+
         G_OBJECT_CLASS (dh_book_manager_parent_class)->finalize (object);
 }
 
@@ -117,6 +129,7 @@ dh_book_manager_class_init (DhBookManagerClass *klass)
 {
         GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
+        object_class->dispose = dh_book_manager_dispose;
         object_class->finalize = dh_book_manager_finalize;
         object_class->set_property = dh_book_manager_set_property;
         object_class->get_property = dh_book_manager_get_property;


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