[mousetweaks] Make singleton classes reusable



commit 5b450e33d810a5a9a8565f7d727613ab272bf2de
Author: Gerd Kohlberger <gerdk src gnome org>
Date:   Tue Jun 22 15:47:33 2010 +0200

    Make singleton classes reusable

 src/mt-cursor-manager.c |    4 +++-
 src/mt-listener.c       |    4 +++-
 src/mt-service.c        |    4 +++-
 3 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/mt-cursor-manager.c b/src/mt-cursor-manager.c
index 95f5871..b32b9ef 100644
--- a/src/mt-cursor-manager.c
+++ b/src/mt-cursor-manager.c
@@ -253,8 +253,10 @@ mt_cursor_manager_get_default (void)
     static MtCursorManager *manager = NULL;
 
     if (!manager)
+    {
         manager = g_object_new (MT_TYPE_CURSOR_MANAGER, NULL);
-
+        g_object_add_weak_pointer (G_OBJECT (manager), (gpointer *) &manager);
+    }
     return manager;
 }
 
diff --git a/src/mt-listener.c b/src/mt-listener.c
index 864bbc7..1d4978d 100644
--- a/src/mt-listener.c
+++ b/src/mt-listener.c
@@ -386,7 +386,9 @@ mt_listener_get_default (void)
     static MtListener *listener = NULL;
 
     if (!listener)
+    {
         listener = g_object_new (MT_TYPE_LISTENER, NULL);
-
+        g_object_add_weak_pointer (G_OBJECT (listener), (gpointer *) &listener);
+    }
     return listener;
 }
diff --git a/src/mt-service.c b/src/mt-service.c
index 4be8112..45bc1f8 100644
--- a/src/mt-service.c
+++ b/src/mt-service.c
@@ -256,8 +256,10 @@ mt_service_get_default (void)
     static MtService *service = NULL;
 
     if (!service)
+    {
         service = g_object_new (MT_TYPE_SERVICE, NULL);
-
+        g_object_add_weak_pointer (G_OBJECT (service), (gpointer *) &service);
+    }
     return service;
 }
 



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