[gnome-color-manager] trivial: make GcmColorimeter a singleton to save a few bytes of writable
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] trivial: make GcmColorimeter a singleton to save a few bytes of writable
- Date: Mon, 22 Feb 2010 14:25:10 +0000 (UTC)
commit 829c6cf0edfe0d2226b7417b223b4e2730839b4d
Author: Richard Hughes <richard hughsie com>
Date: Mon Feb 22 14:20:12 2010 +0000
trivial: make GcmColorimeter a singleton to save a few bytes of writable
src/gcm-colorimeter.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/src/gcm-colorimeter.c b/src/gcm-colorimeter.c
index b6a3536..366ed0a 100644
--- a/src/gcm-colorimeter.c
+++ b/src/gcm-colorimeter.c
@@ -75,6 +75,7 @@ enum {
};
static guint signals[SIGNAL_LAST] = { 0 };
+static gpointer gcm_colorimeter_object = NULL;
G_DEFINE_TYPE (GcmColorimeter, gcm_colorimeter, G_TYPE_OBJECT)
@@ -480,8 +481,12 @@ gcm_colorimeter_finalize (GObject *object)
GcmColorimeter *
gcm_colorimeter_new (void)
{
- GcmColorimeter *colorimeter;
- colorimeter = g_object_new (GCM_TYPE_COLORIMETER, NULL);
- return GCM_COLORIMETER (colorimeter);
+ if (gcm_colorimeter_object != NULL) {
+ g_object_ref (gcm_colorimeter_object);
+ } else {
+ gcm_colorimeter_object = g_object_new (GCM_TYPE_COLORIMETER, NULL);
+ g_object_add_weak_pointer (gcm_colorimeter_object, &gcm_colorimeter_object);
+ }
+ return GCM_COLORIMETER (gcm_colorimeter_object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]