[cheese/gnome-2-28] Make CheeseGConf a singleton object



commit f1597108a91e59894dbde7dcb3eeb439948d7e83
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Nov 27 16:49:43 2009 +0000

    Make CheeseGConf a singleton object
    
    Thus saving us some RAM by avoiding 2 copies of an object that
    does the exact same thing.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=603161

 src/cheese-gconf.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/src/cheese-gconf.c b/src/cheese-gconf.c
index 015e8e1..b3e2c64 100644
--- a/src/cheese-gconf.c
+++ b/src/cheese-gconf.c
@@ -493,8 +493,14 @@ cheese_gconf_init (CheeseGConf *gconf)
 CheeseGConf *
 cheese_gconf_new ()
 {
-  CheeseGConf *gconf;
+  static CheeseGConf *gconf = NULL;
+
+  if (gconf != NULL)
+	  return g_object_ref (gconf);
 
   gconf = g_object_new (CHEESE_TYPE_GCONF, NULL);
+  g_object_add_weak_pointer (G_OBJECT (gconf),
+			     (gpointer) &gconf);
+
   return gconf;
 }



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