[gnome-settings-daemon] main: Make GnomeSettingsSession a singleton



commit 4845334fe76e7fddea1fc8870ed6c236d3353fb1
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Oct 20 20:14:45 2012 -0400

    main: Make GnomeSettingsSession a singleton
    
    There is no need at all to do the listening for systemd or
    ConsoleKit signals more than once in the gnome-settings-daemon
    process.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=686554

 gnome-settings-daemon/gnome-settings-session.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/gnome-settings-daemon/gnome-settings-session.c b/gnome-settings-daemon/gnome-settings-session.c
index 5a96e44..e404a34 100644
--- a/gnome-settings-daemon/gnome-settings-session.c
+++ b/gnome-settings-daemon/gnome-settings-session.c
@@ -248,12 +248,19 @@ gnome_settings_session_finalize (GObject *object)
 	G_OBJECT_CLASS (gnome_settings_session_parent_class)->finalize (object);
 }
 
+static GnomeSettingsSession *session;
+
 GnomeSettingsSession *
 gnome_settings_session_new (void)
 {
-	GnomeSettingsSession *session;
-	session = g_object_new (GNOME_TYPE_SETTINGS_SESSION, NULL);
-	return GNOME_SETTINGS_SESSION (session);
+        if (session != NULL) {
+                g_object_ref (session);
+        } else {
+                session = g_object_new (GNOME_TYPE_SETTINGS_SESSION, NULL);
+                g_object_add_weak_pointer ((GObject*)session, (gpointer*)&session);
+        }
+
+	return session;
 }
 
 #define GNOME_SESSION_DBUS_NAME      "org.gnome.SessionManager"



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