[cheese] Make CheeseFileUtil a singleton



commit d7284520cdd75df1ba1aa72eacae1e9de71bc649
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Nov 27 16:53:39 2009 +0000

    Make CheeseFileUtil a singleton
    
    And save even more RAM! And polar bears!
    
    https://bugzilla.gnome.org/show_bug.cgi?id=603162

 src/cheese-fileutil.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/src/cheese-fileutil.c b/src/cheese-fileutil.c
index e232153..4739327 100644
--- a/src/cheese-fileutil.c
+++ b/src/cheese-fileutil.c
@@ -237,8 +237,13 @@ cheese_fileutil_init (CheeseFileUtil *fileutil)
 CheeseFileUtil *
 cheese_fileutil_new ()
 {
-  CheeseFileUtil *fileutil;
+  static CheeseFileUtil *fileutil = NULL;
+
+  if (fileutil != NULL)
+    return g_object_ref (fileutil);
 
   fileutil = g_object_new (CHEESE_TYPE_FILEUTIL, NULL);
+  g_object_add_weak_pointer (G_OBJECT (fileutil),
+			     (gpointer) &fileutil);
   return fileutil;
 }



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