This is an automated email from the git hooks/post-receive script.

nomad pushed a 
commit to branch 
master
in repository apps/xfdashboard.

commit 11886db92b89f2e34adc18293e46eeb9d2d2ce4f
Author: Stephan Haller <no...@froevel.de>
Date:   Fri Feb 9 10:16:41 2018 +0100

    Hardening creation of singleton except window tracker related ones as they 
are too dynamic.
---
 libxfdashboard/application-database.c | 50 +++++++++++++++++++++++++++-------
 libxfdashboard/application-tracker.c  | 45 +++++++++++++++++++++++++------
 libxfdashboard/bindings-pool.c        | 47 +++++++++++++++++++++++++++-----
 libxfdashboard/focus-manager.c        | 51 ++++++++++++++++++++++++++++-------
 libxfdashboard/plugins-manager.c      | 50 +++++++++++++++++++++++++++-------
 libxfdashboard/search-manager.c       | 50 +++++++++++++++++++++++++++-------
 libxfdashboard/view-manager.c         | 50 +++++++++++++++++++++++++++-------
 7 files changed, 283 insertions(+), 60 deletions(-)

diff --git a/libxfdashboard/application-database.c 
b/libxfdashboard/application-database.c
index 22bbc4b..f8530f7 100644
--- a/libxfdashboard/application-database.c
+++ b/libxfdashboard/application-database.c
@@ -1236,11 +1236,33 @@ static void 
_xfdashboard_application_database_check_search_path_duplicate(gpoint
 
 /* IMPLEMENTATION: GObject */
 
+/* Construct this object */
+static GObject* _xfdashboard_application_database_constructor(GType inType,
+                                                                               
                                                guint inNumberConstructParams,
+                                                                               
                                                GObjectConstructParam 
*inConstructParams)
+{
+       GObject                                                                 
*object;
+
+       if(!_xfdashboard_application_database)
+       {
+               
object=G_OBJECT_CLASS(xfdashboard_application_database_parent_class)->constructor(inType,
 inNumberConstructParams, inConstructParams);
+               
_xfdashboard_application_database=XFDASHBOARD_APPLICATION_DATABASE(object);
+g_message("%s: Created singleton for application database %p", __func__, 
_xfdashboard_application_database);
+       }
+               else
+               {
+                       
object=g_object_ref(G_OBJECT(_xfdashboard_application_database));
+g_message("%s: Increased reference counter to %u for singleton of application 
database %p", __func__, G_OBJECT(_xfdashboard_application_database)->ref_count, 
_xfdashboard_application_database);
+               }
+
+       return(object);
+}
+
 /* Dispose this object */
 static void _xfdashboard_application_database_dispose(GObject *inObject)
 {
-       XfdashboardApplicationDatabase                                          
        *self=XFDASHBOARD_APPLICATION_DATABASE(inObject);
-       XfdashboardApplicationDatabasePrivate                                   
*priv=self->priv;
+       XfdashboardApplicationDatabase                  
*self=XFDASHBOARD_APPLICATION_DATABASE(inObject);
+       XfdashboardApplicationDatabasePrivate   *priv=self->priv;
 
        /* Release allocated resources */
        _xfdashboard_application_database_clean(self);
@@ -1251,14 +1273,23 @@ static void 
_xfdashboard_application_database_dispose(GObject *inObject)
                priv->searchPaths=NULL;
        }
 
-       /* Unset singleton */
+       /* Call parent's class dispose method */
+       
G_OBJECT_CLASS(xfdashboard_application_database_parent_class)->dispose(inObject);
+g_message("%s: Decreased reference counter to %u for singleton of application 
database %p", __func__, G_OBJECT(_xfdashboard_application_database)->ref_count, 
_xfdashboard_application_database);
+}
+
+/* Finalize this object */
+static void _xfdashboard_application_database_finalize(GObject *inObject)
+{
+       /* Release allocated resources finally, e.g. unset singleton */
        if(G_LIKELY(G_OBJECT(_xfdashboard_application_database)==inObject))
        {
+g_message("%s: Finally unset application database %p", __func__, 
_xfdashboard_application_database);
                _xfdashboard_application_database=NULL;
        }
 
        /* Call parent's class dispose method */
-       
G_OBJECT_CLASS(xfdashboard_application_database_parent_class)->dispose(inObject);
+       
G_OBJECT_CLASS(xfdashboard_application_database_parent_class)->finalize(inObject);
 }
 
 /* Set/get properties */
@@ -1291,7 +1322,9 @@ static void 
xfdashboard_application_database_class_init(XfdashboardApplicationDa
        GObjectClass            *gobjectClass=G_OBJECT_CLASS(klass);
 
        /* Override functions */
+       gobjectClass->constructor=_xfdashboard_application_database_constructor;
        gobjectClass->dispose=_xfdashboard_application_database_dispose;
+       gobjectClass->finalize=_xfdashboard_application_database_finalize;
        
gobjectClass->get_property=_xfdashboard_application_database_get_property;
 
        /* Set up private structure */
@@ -1405,13 +1438,10 @@ static void 
xfdashboard_application_database_init(XfdashboardApplicationDatabase
 /* Get single instance of application */
 XfdashboardApplicationDatabase* 
xfdashboard_application_database_get_default(void)
 {
-       if(G_UNLIKELY(_xfdashboard_application_database==NULL))
-       {
-               
_xfdashboard_application_database=g_object_new(XFDASHBOARD_TYPE_APPLICATION_DATABASE,
 NULL);
-       }
-               else g_object_ref(_xfdashboard_application_database);
+       GObject                                                                 
*singleton;
 
-       return(_xfdashboard_application_database);
+       singleton=g_object_new(XFDASHBOARD_TYPE_APPLICATION_DATABASE, NULL);
+       return(XFDASHBOARD_APPLICATION_DATABASE(singleton));
 }
 
 /* Determine if menu and applications has been loaded successfully */
diff --git a/libxfdashboard/application-tracker.c 
b/libxfdashboard/application-tracker.c
index af0e31d..af1eef0 100644
--- a/libxfdashboard/application-tracker.c
+++ b/libxfdashboard/application-tracker.c
@@ -931,6 +931,28 @@ static void 
_xfdashboard_application_tracker_on_active_window_changed(Xfdashboar
 
 /* IMPLEMENTATION: GObject */
 
+/* Construct this object */
+static GObject* _xfdashboard_application_tracker_constructor(GType inType,
+                                                                               
                                                guint inNumberConstructParams,
+                                                                               
                                                GObjectConstructParam 
*inConstructParams)
+{
+       GObject                                                                 
*object;
+
+       if(!_xfdashboard_application_tracker)
+       {
+               
object=G_OBJECT_CLASS(xfdashboard_application_tracker_parent_class)->constructor(inType,
 inNumberConstructParams, inConstructParams);
+               
_xfdashboard_application_tracker=XFDASHBOARD_APPLICATION_TRACKER(object);
+g_message("%s: Created singleton for application tracker %p", __func__, 
_xfdashboard_application_tracker);
+       }
+               else
+               {
+                       
object=g_object_ref(G_OBJECT(_xfdashboard_application_tracker));
+g_message("%s: Increased reference counter to %u for singleton of application 
tracker %p", __func__, G_OBJECT(_xfdashboard_application_tracker)->ref_count, 
_xfdashboard_application_tracker);
+               }
+
+       return(object);
+}
+
 /* Dispose this object */
 static void _xfdashboard_application_tracker_dispose(GObject *inObject)
 {
@@ -957,14 +979,22 @@ static void 
_xfdashboard_application_tracker_dispose(GObject *inObject)
                priv->appDatabase=NULL;
        }
 
-       /* Unset singleton */
+       /* Call parent's class dispose method */
+       
G_OBJECT_CLASS(xfdashboard_application_tracker_parent_class)->dispose(inObject);
+}
+
+/* Finalize this object */
+static void _xfdashboard_application_tracker_finalize(GObject *inObject)
+{
+       /* Release allocated resources finally, e.g. unset singleton */
        if(G_LIKELY(G_OBJECT(_xfdashboard_application_tracker)==inObject))
        {
+g_message("%s: Finally unset application tracker %p", __func__, 
_xfdashboard_application_tracker);
                _xfdashboard_application_tracker=NULL;
        }
 
        /* Call parent's class dispose method */
-       
G_OBJECT_CLASS(xfdashboard_application_tracker_parent_class)->dispose(inObject);
+       
G_OBJECT_CLASS(xfdashboard_application_tracker_parent_class)->finalize(inObject);
 }
 
 /* Class initialization
@@ -976,7 +1006,9 @@ static void 
xfdashboard_application_tracker_class_init(XfdashboardApplicationTra
        GObjectClass            *gobjectClass=G_OBJECT_CLASS(klass);
 
        /* Override functions */
+       gobjectClass->constructor=_xfdashboard_application_tracker_constructor;
        gobjectClass->dispose=_xfdashboard_application_tracker_dispose;
+       gobjectClass->finalize=_xfdashboard_application_tracker_finalize;
 
        /* Set up private structure */
        g_type_class_add_private(klass, 
sizeof(XfdashboardApplicationTrackerPrivate));
@@ -1036,13 +1068,10 @@ static void 
xfdashboard_application_tracker_init(XfdashboardApplicationTracker *
 /* Get single instance of application */
 XfdashboardApplicationTracker* 
xfdashboard_application_tracker_get_default(void)
 {
-       if(G_UNLIKELY(_xfdashboard_application_tracker==NULL))
-       {
-               
_xfdashboard_application_tracker=g_object_new(XFDASHBOARD_TYPE_APPLICATION_TRACKER,
 NULL);
-       }
-               else g_object_ref(_xfdashboard_application_tracker);
+       GObject                                                                 
*singleton;
 
-       return(_xfdashboard_application_tracker);
+       singleton=g_object_new(XFDASHBOARD_TYPE_APPLICATION_TRACKER, NULL);
+       return(XFDASHBOARD_APPLICATION_TRACKER(singleton));
 }
 
 /* Get running state of application */
diff --git a/libxfdashboard/bindings-pool.c b/libxfdashboard/bindings-pool.c
index 14bcb02..70e49d9 100644
--- a/libxfdashboard/bindings-pool.c
+++ b/libxfdashboard/bindings-pool.c
@@ -941,6 +941,28 @@ static gboolean 
_xfdashboard_bindings_pool_load_bindings_from_file(XfdashboardBi
 
 /* IMPLEMENTATION: GObject */
 
+/* Construct this object */
+static GObject* _xfdashboard_bindings_pool_constructor(GType inType,
+                                                                               
                                guint inNumberConstructParams,
+                                                                               
                                GObjectConstructParam *inConstructParams)
+{
+       GObject                                                                 
*object;
+
+       if(!_xfdashboard_bindings_pool)
+       {
+               
object=G_OBJECT_CLASS(xfdashboard_bindings_pool_parent_class)->constructor(inType,
 inNumberConstructParams, inConstructParams);
+               _xfdashboard_bindings_pool=XFDASHBOARD_BINDINGS_POOL(object);
+g_message("%s: Created singleton for bindings pool %p", __func__, 
_xfdashboard_bindings_pool);
+       }
+               else
+               {
+                       
object=g_object_ref(G_OBJECT(_xfdashboard_bindings_pool));
+g_message("%s: Increased reference counter to %u for singleton of bindings 
pool %p", __func__, G_OBJECT(_xfdashboard_bindings_pool)->ref_count, 
_xfdashboard_bindings_pool);
+               }
+
+       return(object);
+}
+
 /* Dispose this object */
 static void _xfdashboard_bindings_pool_dispose(GObject *inObject)
 {
@@ -958,6 +980,20 @@ static void _xfdashboard_bindings_pool_dispose(GObject 
*inObject)
        
G_OBJECT_CLASS(xfdashboard_bindings_pool_parent_class)->dispose(inObject);
 }
 
+/* Finalize this object */
+static void _xfdashboard_bindings_pool_finalize(GObject *inObject)
+{
+       /* Release allocated resources finally, e.g. unset singleton */
+       if(G_LIKELY(G_OBJECT(_xfdashboard_bindings_pool)==inObject))
+       {
+g_message("%s: Finally unset bindings pool %p", __func__, 
_xfdashboard_bindings_pool);
+               _xfdashboard_bindings_pool=NULL;
+       }
+
+       /* Call parent's class dispose method */
+       
G_OBJECT_CLASS(xfdashboard_bindings_pool_parent_class)->finalize(inObject);
+}
+
 /* Class initialization
  * Override functions in parent classes and define properties
  * and signals
@@ -967,7 +1003,9 @@ static void 
xfdashboard_bindings_pool_class_init(XfdashboardBindingsPoolClass *k
        GObjectClass                                    
*gobjectClass=G_OBJECT_CLASS(klass);
 
        /* Override functions */
+       gobjectClass->constructor=_xfdashboard_bindings_pool_constructor;
        gobjectClass->dispose=_xfdashboard_bindings_pool_dispose;
+       gobjectClass->finalize=_xfdashboard_bindings_pool_finalize;
 
        /* Set up private structure */
        g_type_class_add_private(klass, sizeof(XfdashboardBindingsPoolPrivate));
@@ -998,13 +1036,10 @@ GQuark xfdashboard_bindings_pool_error_quark(void)
 /* Get single instance of manager */
 XfdashboardBindingsPool* xfdashboard_bindings_pool_get_default(void)
 {
-       if(G_UNLIKELY(_xfdashboard_bindings_pool==NULL))
-       {
-               
_xfdashboard_bindings_pool=g_object_new(XFDASHBOARD_TYPE_BINDINGS_POOL, NULL);
-       }
-               else g_object_ref(_xfdashboard_bindings_pool);
+       GObject                                                                 
*singleton;
 
-       return(_xfdashboard_bindings_pool);
+       singleton=g_object_new(XFDASHBOARD_TYPE_BINDINGS_POOL, NULL);
+       return(XFDASHBOARD_BINDINGS_POOL(singleton));
 }
 
 /* Load bindings from configuration file */
diff --git a/libxfdashboard/focus-manager.c b/libxfdashboard/focus-manager.c
index 5ac2bd6..e99a4b9 100644
--- a/libxfdashboard/focus-manager.c
+++ b/libxfdashboard/focus-manager.c
@@ -327,6 +327,28 @@ static gboolean 
_xfdashboard_focus_manager_move_focus_previous(XfdashboardFocusM
 
 /* IMPLEMENTATION: GObject */
 
+/* Construct this object */
+static GObject* _xfdashboard_focus_manager_constructor(GType inType,
+                                                                               
                                guint inNumberConstructParams,
+                                                                               
                                GObjectConstructParam *inConstructParams)
+{
+       GObject                                                                 
*object;
+
+       if(!_xfdashboard_focus_manager)
+       {
+               
object=G_OBJECT_CLASS(xfdashboard_focus_manager_parent_class)->constructor(inType,
 inNumberConstructParams, inConstructParams);
+               _xfdashboard_focus_manager=XFDASHBOARD_FOCUS_MANAGER(object);
+g_message("%s: Created singleton for focus manager %p", __func__, 
_xfdashboard_focus_manager);
+       }
+               else
+               {
+                       
object=g_object_ref(G_OBJECT(_xfdashboard_focus_manager));
+g_message("%s: Increased reference counter to %u for singleton of focus 
manager %p", __func__, G_OBJECT(_xfdashboard_focus_manager)->ref_count, 
_xfdashboard_focus_manager);
+               }
+
+       return(object);
+}
+
 /* Dispose this object */
 static void _xfdashboard_focus_manager_dispose_unregister_focusable(gpointer 
inData, gpointer inUserData)
 {
@@ -366,13 +388,25 @@ static void _xfdashboard_focus_manager_dispose(GObject 
*inObject)
                priv->registeredFocusables=NULL;
        }
 
-       /* Unset singleton */
-       if(G_LIKELY(G_OBJECT(_xfdashboard_focus_manager)==inObject)) 
_xfdashboard_focus_manager=NULL;
-
        /* Call parent's class dispose method */
        
G_OBJECT_CLASS(xfdashboard_focus_manager_parent_class)->dispose(inObject);
 }
 
+/* Finalize this object */
+static void _xfdashboard_focus_manager_finalize(GObject *inObject)
+{
+       /* Release allocated resources finally, e.g. unset singleton */
+       if(G_LIKELY(G_OBJECT(_xfdashboard_focus_manager)==inObject))
+       {
+g_message("%s: Finally unset focus manager %p", __func__, 
_xfdashboard_focus_manager);
+               _xfdashboard_focus_manager=NULL;
+       }
+
+       /* Call parent's class dispose method */
+       
G_OBJECT_CLASS(xfdashboard_focus_manager_parent_class)->finalize(inObject);
+}
+
+
 /* Class initialization
  * Override functions in parent classes and define properties
  * and signals
@@ -382,7 +416,9 @@ static void 
xfdashboard_focus_manager_class_init(XfdashboardFocusManagerClass *k
        GObjectClass            *gobjectClass=G_OBJECT_CLASS(klass);
 
        /* Override functions */
+       gobjectClass->constructor=_xfdashboard_focus_manager_constructor;
        gobjectClass->dispose=_xfdashboard_focus_manager_dispose;
+       gobjectClass->finalize=_xfdashboard_focus_manager_finalize;
 
        klass->focus_move_first=_xfdashboard_focus_manager_move_focus_first;
        klass->focus_move_last=_xfdashboard_focus_manager_move_focus_last;
@@ -506,13 +542,10 @@ static void 
xfdashboard_focus_manager_init(XfdashboardFocusManager *self)
 /* Get single instance of manager */
 XfdashboardFocusManager* xfdashboard_focus_manager_get_default(void)
 {
-       if(G_UNLIKELY(_xfdashboard_focus_manager==NULL))
-       {
-               
_xfdashboard_focus_manager=g_object_new(XFDASHBOARD_TYPE_FOCUS_MANAGER, NULL);
-       }
-               else g_object_ref(_xfdashboard_focus_manager);
+       GObject                                                                 
*singleton;
 
-       return(_xfdashboard_focus_manager);
+       singleton=g_object_new(XFDASHBOARD_TYPE_FOCUS_MANAGER, NULL);
+       return(XFDASHBOARD_FOCUS_MANAGER(singleton));
 }
 
 /* Register a focusable actor */
diff --git a/libxfdashboard/plugins-manager.c b/libxfdashboard/plugins-manager.c
index a2f54fb..e8725c9 100644
--- a/libxfdashboard/plugins-manager.c
+++ b/libxfdashboard/plugins-manager.c
@@ -504,6 +504,28 @@ static void 
_xfdashboard_plugins_manager_on_application_initialized(XfdashboardP
 
 /* IMPLEMENTATION: GObject */
 
+/* Construct this object */
+static GObject* _xfdashboard_plugins_manager_constructor(GType inType,
+                                                                               
                                        guint inNumberConstructParams,
+                                                                               
                                        GObjectConstructParam 
*inConstructParams)
+{
+       GObject                                                                 
*object;
+
+       if(!_xfdashboard_plugins_manager)
+       {
+               
object=G_OBJECT_CLASS(xfdashboard_plugins_manager_parent_class)->constructor(inType,
 inNumberConstructParams, inConstructParams);
+               
_xfdashboard_plugins_manager=XFDASHBOARD_PLUGINS_MANAGER(object);
+g_message("%s: Created singleton for plugins manager %p", __func__, 
_xfdashboard_plugins_manager);
+       }
+               else
+               {
+                       
object=g_object_ref(G_OBJECT(_xfdashboard_plugins_manager));
+g_message("%s: Increased reference counter to %u for singleton of plugins 
manager %p", __func__, G_OBJECT(_xfdashboard_plugins_manager)->ref_count, 
_xfdashboard_plugins_manager);
+               }
+
+       return(object);
+}
+
 /* Dispose this object */
 static void _xfdashboard_plugins_manager_dispose_remove_plugin(gpointer inData)
 {
@@ -549,13 +571,24 @@ static void _xfdashboard_plugins_manager_dispose(GObject 
*inObject)
                priv->searchPaths=NULL;
        }
 
-       /* Unset singleton */
-       if(G_LIKELY(G_OBJECT(_xfdashboard_plugins_manager)==inObject)) 
_xfdashboard_plugins_manager=NULL;
-
        /* Call parent's class dispose method */
        
G_OBJECT_CLASS(xfdashboard_plugins_manager_parent_class)->dispose(inObject);
 }
 
+/* Finalize this object */
+static void _xfdashboard_plugins_manager_finalize(GObject *inObject)
+{
+       /* Release allocated resources finally, e.g. unset singleton */
+       if(G_LIKELY(G_OBJECT(_xfdashboard_plugins_manager)==inObject))
+       {
+g_message("%s: Finally unset plugins manager %p", __func__, 
_xfdashboard_plugins_manager);
+               _xfdashboard_plugins_manager=NULL;
+       }
+
+       /* Call parent's class dispose method */
+       
G_OBJECT_CLASS(xfdashboard_plugins_manager_parent_class)->finalize(inObject);
+}
+
 /* Class initialization
  * Override functions in parent classes and define properties
  * and signals
@@ -565,7 +598,9 @@ static void 
xfdashboard_plugins_manager_class_init(XfdashboardPluginsManagerClas
        GObjectClass            *gobjectClass=G_OBJECT_CLASS(klass);
 
        /* Override functions */
+       gobjectClass->constructor=_xfdashboard_plugins_manager_constructor;
        gobjectClass->dispose=_xfdashboard_plugins_manager_dispose;
+       gobjectClass->finalize=_xfdashboard_plugins_manager_finalize;
 
        /* Set up private structure */
        g_type_class_add_private(klass, 
sizeof(XfdashboardPluginsManagerPrivate));
@@ -617,13 +652,10 @@ static void 
xfdashboard_plugins_manager_init(XfdashboardPluginsManager *self)
  */
 XfdashboardPluginsManager* xfdashboard_plugins_manager_get_default(void)
 {
-       if(G_UNLIKELY(_xfdashboard_plugins_manager==NULL))
-       {
-               
_xfdashboard_plugins_manager=g_object_new(XFDASHBOARD_TYPE_PLUGINS_MANAGER, 
NULL);
-       }
-               else g_object_ref(_xfdashboard_plugins_manager);
+       GObject                                                                 
*singleton;
 
-       return(_xfdashboard_plugins_manager);
+       singleton=g_object_new(XFDASHBOARD_TYPE_PLUGINS_MANAGER, NULL);
+       return(XFDASHBOARD_PLUGINS_MANAGER(singleton));
 }
 
 /**
diff --git a/libxfdashboard/search-manager.c b/libxfdashboard/search-manager.c
index 30289f1..db1c1ac 100644
--- a/libxfdashboard/search-manager.c
+++ b/libxfdashboard/search-manager.c
@@ -157,6 +157,28 @@ static XfdashboardSearchManagerData* 
_xfdashboard_search_manager_entry_find_data
 
 /* IMPLEMENTATION: GObject */
 
+/* Construct this object */
+static GObject* _xfdashboard_search_manager_constructor(GType inType,
+                                                                               
                                guint inNumberConstructParams,
+                                                                               
                                GObjectConstructParam *inConstructParams)
+{
+       GObject                                                                 
*object;
+
+       if(!_xfdashboard_search_manager)
+       {
+               
object=G_OBJECT_CLASS(xfdashboard_search_manager_parent_class)->constructor(inType,
 inNumberConstructParams, inConstructParams);
+               _xfdashboard_search_manager=XFDASHBOARD_SEARCH_MANAGER(object);
+g_message("%s: Created singleton for search manager %p", __func__, 
_xfdashboard_search_manager);
+       }
+               else
+               {
+                       
object=g_object_ref(G_OBJECT(_xfdashboard_search_manager));
+g_message("%s: Increased reference counter to %u for singleton of search 
manager %p", __func__, G_OBJECT(_xfdashboard_search_manager)->ref_count, 
_xfdashboard_search_manager);
+               }
+
+       return(object);
+}
+
 /* Dispose this object */
 static void 
_xfdashboard_search_manager_dispose_unregister_search_provider(gpointer inData, 
gpointer inUserData)
 {
@@ -181,13 +203,24 @@ static void _xfdashboard_search_manager_dispose(GObject 
*inObject)
                priv->registeredProviders=NULL;
        }
 
-       /* Unset singleton */
-       if(G_LIKELY(G_OBJECT(_xfdashboard_search_manager)==inObject)) 
_xfdashboard_search_manager=NULL;
-
        /* Call parent's class dispose method */
        
G_OBJECT_CLASS(xfdashboard_search_manager_parent_class)->dispose(inObject);
 }
 
+/* Finalize this object */
+static void _xfdashboard_search_manager_finalize(GObject *inObject)
+{
+       /* Release allocated resources finally, e.g. unset singleton */
+       if(G_LIKELY(G_OBJECT(_xfdashboard_search_manager)==inObject))
+       {
+g_message("%s: Finally unset search manager %p", __func__, 
_xfdashboard_search_manager);
+               _xfdashboard_search_manager=NULL;
+       }
+
+       /* Call parent's class dispose method */
+       
G_OBJECT_CLASS(xfdashboard_search_manager_parent_class)->finalize(inObject);
+}
+
 /* Class initialization
  * Override functions in parent classes and define properties
  * and signals
@@ -197,7 +230,9 @@ static void 
xfdashboard_search_manager_class_init(XfdashboardSearchManagerClass
        GObjectClass            *gobjectClass=G_OBJECT_CLASS(klass);
 
        /* Override functions */
+       gobjectClass->constructor=_xfdashboard_search_manager_constructor;
        gobjectClass->dispose=_xfdashboard_search_manager_dispose;
+       gobjectClass->finalize=_xfdashboard_search_manager_finalize;
 
        /* Set up private structure */
        g_type_class_add_private(klass, 
sizeof(XfdashboardSearchManagerPrivate));
@@ -246,13 +281,10 @@ static void 
xfdashboard_search_manager_init(XfdashboardSearchManager *self)
 /* Get single instance of manager */
 XfdashboardSearchManager* xfdashboard_search_manager_get_default(void)
 {
-       if(G_UNLIKELY(_xfdashboard_search_manager==NULL))
-       {
-               
_xfdashboard_search_manager=g_object_new(XFDASHBOARD_TYPE_SEARCH_MANAGER, NULL);
-       }
-               else g_object_ref(_xfdashboard_search_manager);
+       GObject                                                                 
*singleton;
 
-       return(_xfdashboard_search_manager);
+       singleton=g_object_new(XFDASHBOARD_TYPE_SEARCH_MANAGER, NULL);
+       return(XFDASHBOARD_SEARCH_MANAGER(singleton));
 }
 
 /* Register a search provider */
diff --git a/libxfdashboard/view-manager.c b/libxfdashboard/view-manager.c
index abbc99b..8bf1363 100644
--- a/libxfdashboard/view-manager.c
+++ b/libxfdashboard/view-manager.c
@@ -152,6 +152,28 @@ static XfdashboardViewManagerData* 
_xfdashboard_view_manager_entry_find_data_by_
 
 /* IMPLEMENTATION: GObject */
 
+/* Construct this object */
+static GObject* _xfdashboard_view_manager_constructor(GType inType,
+                                                                               
                                guint inNumberConstructParams,
+                                                                               
                                GObjectConstructParam *inConstructParams)
+{
+       GObject                                                                 
*object;
+
+       if(!_xfdashboard_view_manager)
+       {
+               
object=G_OBJECT_CLASS(xfdashboard_view_manager_parent_class)->constructor(inType,
 inNumberConstructParams, inConstructParams);
+               _xfdashboard_view_manager=XFDASHBOARD_VIEW_MANAGER(object);
+g_message("%s: Created singleton for view manager %p", __func__, 
_xfdashboard_view_manager);
+       }
+               else
+               {
+                       
object=g_object_ref(G_OBJECT(_xfdashboard_view_manager));
+g_message("%s: Increased reference counter to %u for singleton of view manager 
%p", __func__, G_OBJECT(_xfdashboard_view_manager)->ref_count, 
_xfdashboard_view_manager);
+               }
+
+       return(object);
+}
+
 /* Dispose this object */
 static void _xfdashboard_view_manager_dispose_unregister_view(gpointer inData, 
gpointer inUserData)
 {
@@ -176,13 +198,24 @@ static void _xfdashboard_view_manager_dispose(GObject 
*inObject)
                priv->registeredViews=NULL;
        }
 
-       /* Unset singleton */
-       if(G_LIKELY(G_OBJECT(_xfdashboard_view_manager)==inObject)) 
_xfdashboard_view_manager=NULL;
-
        /* Call parent's class dispose method */
        
G_OBJECT_CLASS(xfdashboard_view_manager_parent_class)->dispose(inObject);
 }
 
+/* Finalize this object */
+static void _xfdashboard_view_manager_finalize(GObject *inObject)
+{
+       /* Release allocated resources finally, e.g. unset singleton */
+       if(G_LIKELY(G_OBJECT(_xfdashboard_view_manager)==inObject))
+       {
+g_message("%s: Finally unset view manager %p", __func__, 
_xfdashboard_view_manager);
+               _xfdashboard_view_manager=NULL;
+       }
+
+       /* Call parent's class dispose method */
+       
G_OBJECT_CLASS(xfdashboard_view_manager_parent_class)->finalize(inObject);
+}
+
 /* Class initialization
  * Override functions in parent classes and define properties
  * and signals
@@ -192,7 +225,9 @@ static void 
xfdashboard_view_manager_class_init(XfdashboardViewManagerClass *kla
        GObjectClass            *gobjectClass=G_OBJECT_CLASS(klass);
 
        /* Override functions */
+       gobjectClass->constructor=_xfdashboard_view_manager_constructor;
        gobjectClass->dispose=_xfdashboard_view_manager_dispose;
+       gobjectClass->finalize=_xfdashboard_view_manager_finalize;
 
        /* Set up private structure */
        g_type_class_add_private(klass, sizeof(XfdashboardViewManagerPrivate));
@@ -241,13 +276,10 @@ static void 
xfdashboard_view_manager_init(XfdashboardViewManager *self)
 /* Get single instance of manager */
 XfdashboardViewManager* xfdashboard_view_manager_get_default(void)
 {
-       if(G_UNLIKELY(_xfdashboard_view_manager==NULL))
-       {
-               
_xfdashboard_view_manager=g_object_new(XFDASHBOARD_TYPE_VIEW_MANAGER, NULL);
-       }
-               else g_object_ref(_xfdashboard_view_manager);
+       GObject                                                                 
*singleton;
 
-       return(_xfdashboard_view_manager);
+       singleton=g_object_new(XFDASHBOARD_TYPE_VIEW_MANAGER, NULL);
+       return(XFDASHBOARD_VIEW_MANAGER(singleton));
 }
 
 /* Register a view */

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
https://mail.xfce.org/mailman/listinfo/xfce4-commits

Reply via email to