[devhelp] Rename functions *_free_singleton() -> *_unref_singleton()



commit 18c9289805bb4d8170e495966492f132aa0a270c
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun May 7 17:22:26 2017 +0200

    Rename functions *_free_singleton() -> *_unref_singleton()
    
    And add comments.

 src/dh-book-manager.c |    7 ++++++-
 src/dh-book-manager.h |    2 +-
 src/dh-init.c         |    4 ++--
 src/dh-settings.c     |    7 ++++++-
 src/dh-settings.h     |    2 +-
 5 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/src/dh-book-manager.c b/src/dh-book-manager.c
index c1c94d4..70eeef4 100644
--- a/src/dh-book-manager.c
+++ b/src/dh-book-manager.c
@@ -841,10 +841,15 @@ dh_book_manager_get_singleton (void)
 }
 
 void
-_dh_book_manager_free_singleton (void)
+_dh_book_manager_unref_singleton (void)
 {
         if (singleton != NULL)
                 g_object_unref (singleton);
+
+        /* singleton is not set to NULL here, it is set to NULL in
+         * dh_book_manager_finalize() (i.e. when we are sure that the ref count
+         * reaches 0).
+         */
 }
 
 /**
diff --git a/src/dh-book-manager.h b/src/dh-book-manager.h
index 5841f52..0a403b6 100644
--- a/src/dh-book-manager.h
+++ b/src/dh-book-manager.h
@@ -55,7 +55,7 @@ G_DEPRECATED
 void           dh_book_manager_populate              (DhBookManager *book_manager);
 
 G_GNUC_INTERNAL
-void           _dh_book_manager_free_singleton       (void);
+void           _dh_book_manager_unref_singleton      (void);
 
 G_END_DECLS
 
diff --git a/src/dh-init.c b/src/dh-init.c
index d85b93a..d0d129c 100644
--- a/src/dh-init.c
+++ b/src/dh-init.c
@@ -79,8 +79,8 @@ dh_free_resources (void)
          * accordingly, at the right place.
          */
         if (!done) {
-                _dh_book_manager_free_singleton ();
-                _dh_settings_free_singleton ();
+                _dh_book_manager_unref_singleton ();
+                _dh_settings_unref_singleton ();
                 done = TRUE;
         }
 }
diff --git a/src/dh-settings.c b/src/dh-settings.c
index d664966..4bc4845 100644
--- a/src/dh-settings.c
+++ b/src/dh-settings.c
@@ -155,10 +155,15 @@ dh_settings_get_singleton (void)
 }
 
 void
-_dh_settings_free_singleton (void)
+_dh_settings_unref_singleton (void)
 {
         if (singleton != NULL)
                 g_object_unref (singleton);
+
+        /* singleton is not set to NULL here, it is set to NULL in
+         * dh_settings_finalize() (i.e. when we are sure that the ref count
+         * reaches 0).
+         */
 }
 
 GSettings *
diff --git a/src/dh-settings.h b/src/dh-settings.h
index b35f194..c977121 100644
--- a/src/dh-settings.h
+++ b/src/dh-settings.h
@@ -54,7 +54,7 @@ GType           dh_settings_get_type                    (void) G_GNUC_CONST;
 DhSettings *    dh_settings_get_singleton               (void);
 
 G_GNUC_INTERNAL
-void            _dh_settings_free_singleton              (void);
+void            _dh_settings_unref_singleton            (void);
 
 GSettings *     dh_settings_peek_window_settings        (DhSettings *self);
 


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