[gnome-color-manager] trivial: make GcmClient a singleton so we can share the instance in the same process
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] trivial: make GcmClient a singleton so we can share the instance in the same process
- Date: Thu, 25 Mar 2010 20:55:31 +0000 (UTC)
commit 99424e82bc9c919a99fe9e031086db68f0a25b3e
Author: Richard Hughes <richard hughsie com>
Date: Thu Mar 25 20:27:45 2010 +0000
trivial: make GcmClient a singleton so we can share the instance in the same process
src/gcm-client.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/src/gcm-client.c b/src/gcm-client.c
index 812c32c..57e32a9 100644
--- a/src/gcm-client.c
+++ b/src/gcm-client.c
@@ -88,6 +88,7 @@ enum {
};
static guint signals[SIGNAL_LAST] = { 0 };
+static gpointer gcm_client_object = NULL;
G_DEFINE_TYPE (GcmClient, gcm_client, G_TYPE_OBJECT)
@@ -1335,8 +1336,12 @@ gcm_client_finalize (GObject *object)
GcmClient *
gcm_client_new (void)
{
- GcmClient *client;
- client = g_object_new (GCM_TYPE_CLIENT, NULL);
- return GCM_CLIENT (client);
+ if (gcm_client_object != NULL) {
+ g_object_ref (gcm_client_object);
+ } else {
+ gcm_client_object = g_object_new (GCM_TYPE_CLIENT, NULL);
+ g_object_add_weak_pointer (gcm_client_object, &gcm_client_object);
+ }
+ return GCM_CLIENT (gcm_client_object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]