[devhelp] init: unref singletons only once



commit f6859146e372be532ac0a8469fd7568d5e79f950
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun May 7 17:03:41 2017 +0200

    init: unref singletons only once

 src/dh-init.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/src/dh-init.c b/src/dh-init.c
index 10ba284..d85b93a 100644
--- a/src/dh-init.c
+++ b/src/dh-init.c
@@ -70,6 +70,17 @@ dh_init (void)
 void
 dh_free_resources (void)
 {
-        _dh_book_manager_free_singleton ();
-        _dh_settings_free_singleton ();
+        static gboolean done = FALSE;
+
+        /* Unref the singletons only once, even if this function is called
+         * multiple times, to see if a reference is not released correctly.
+         * Normally the singletons have a ref count of 1. If for some reason the
+         * ref count is increased somewhere, it needs to be decreased
+         * accordingly, at the right place.
+         */
+        if (!done) {
+                _dh_book_manager_free_singleton ();
+                _dh_settings_free_singleton ();
+                done = TRUE;
+        }
 }


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