[liboobs] Make Oobs*Config objects real singletons
- From: Milan Bouchet-Valat <milanbv src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [liboobs] Make Oobs*Config objects real singletons
- Date: Thu, 28 Jan 2010 12:35:43 +0000 (UTC)
commit 6001cb9a62b5b109c1437437195df4976664b3a8
Author: Milan Bouchet-Valat <nalimilan club fr>
Date: Tue Jan 26 16:46:45 2010 +0100
Make Oobs*Config objects real singletons
The documentation for oobs_*_config_get() says the function returns a singleton, but it actually created the object on every call. Fix this by keeping a static reference to it.
oobs/oobs-groupsconfig.c | 11 ++++++++---
oobs/oobs-hostsconfig.c | 11 ++++++++---
oobs/oobs-ifacesconfig.c | 11 ++++++++---
oobs/oobs-nfsconfig.c | 11 ++++++++---
oobs/oobs-ntpconfig.c | 11 ++++++++---
oobs/oobs-selfconfig.c | 11 ++++++++---
oobs/oobs-servicesconfig.c | 11 ++++++++---
oobs/oobs-smbconfig.c | 11 ++++++++---
oobs/oobs-timeconfig.c | 11 ++++++++---
oobs/oobs-usersconfig.c | 11 ++++++++---
10 files changed, 80 insertions(+), 30 deletions(-)
---
diff --git a/oobs/oobs-groupsconfig.c b/oobs/oobs-groupsconfig.c
index f8be200..f54a55c 100644
--- a/oobs/oobs-groupsconfig.c
+++ b/oobs/oobs-groupsconfig.c
@@ -356,9 +356,14 @@ oobs_groups_config_commit (OobsObject *object)
OobsObject*
oobs_groups_config_get (void)
{
- return g_object_new (OOBS_TYPE_GROUPS_CONFIG,
- "remote-object", GROUPS_CONFIG_REMOTE_OBJECT,
- NULL);
+ static OobsObject *the_object = NULL;
+
+ if (!the_object)
+ the_object = g_object_new (OOBS_TYPE_GROUPS_CONFIG,
+ "remote-object", GROUPS_CONFIG_REMOTE_OBJECT,
+ NULL);
+
+ return the_object;
}
/**
diff --git a/oobs/oobs-hostsconfig.c b/oobs/oobs-hostsconfig.c
index 4b4ebd4..162d7a2 100644
--- a/oobs/oobs-hostsconfig.c
+++ b/oobs/oobs-hostsconfig.c
@@ -289,9 +289,14 @@ oobs_hosts_config_commit (OobsObject *object)
OobsObject*
oobs_hosts_config_get (void)
{
- return g_object_new (OOBS_TYPE_HOSTS_CONFIG,
- "remote-object", HOSTS_CONFIG_REMOTE_OBJECT,
- NULL);
+ static OobsObject *the_object = NULL;
+
+ if (!the_object)
+ the_object = g_object_new (OOBS_TYPE_HOSTS_CONFIG,
+ "remote-object", HOSTS_CONFIG_REMOTE_OBJECT,
+ NULL);
+
+ return the_object;
}
/**
diff --git a/oobs/oobs-ifacesconfig.c b/oobs/oobs-ifacesconfig.c
index 45902d2..8b664cc 100644
--- a/oobs/oobs-ifacesconfig.c
+++ b/oobs/oobs-ifacesconfig.c
@@ -798,9 +798,14 @@ oobs_ifaces_config_commit (OobsObject *object)
OobsObject*
oobs_ifaces_config_get (void)
{
- return g_object_new (OOBS_TYPE_IFACES_CONFIG,
- "remote-object", IFACES_CONFIG_REMOTE_OBJECT,
- NULL);
+ static OobsObject *the_object = NULL;
+
+ if (!the_object)
+ the_object = g_object_new (OOBS_TYPE_IFACES_CONFIG,
+ "remote-object", IFACES_CONFIG_REMOTE_OBJECT,
+ NULL);
+
+ return the_object;
}
/**
diff --git a/oobs/oobs-nfsconfig.c b/oobs/oobs-nfsconfig.c
index b365b7a..56460f7 100644
--- a/oobs/oobs-nfsconfig.c
+++ b/oobs/oobs-nfsconfig.c
@@ -255,9 +255,14 @@ oobs_nfs_config_commit (OobsObject *object)
OobsObject*
oobs_nfs_config_get (void)
{
- return g_object_new (OOBS_TYPE_NFS_CONFIG,
- "remote-object", NFS_CONFIG_REMOTE_OBJECT,
- NULL);
+ static OobsObject *the_object = NULL;
+
+ if (!the_object)
+ the_object = g_object_new (OOBS_TYPE_NFS_CONFIG,
+ "remote-object", NFS_CONFIG_REMOTE_OBJECT,
+ NULL);
+
+ return the_object;
}
/**
diff --git a/oobs/oobs-ntpconfig.c b/oobs/oobs-ntpconfig.c
index 904c146..771b725 100644
--- a/oobs/oobs-ntpconfig.c
+++ b/oobs/oobs-ntpconfig.c
@@ -177,9 +177,14 @@ oobs_ntp_config_commit (OobsObject *object)
OobsObject*
oobs_ntp_config_get (void)
{
- return g_object_new (OOBS_TYPE_NTP_CONFIG,
- "remote-object", NTP_CONFIG_REMOTE_OBJECT,
- NULL);
+ static OobsObject *the_object = NULL;
+
+ if (!the_object)
+ the_object = g_object_new (OOBS_TYPE_NTP_CONFIG,
+ "remote-object", NTP_CONFIG_REMOTE_OBJECT,
+ NULL);
+
+ return the_object;
}
/**
diff --git a/oobs/oobs-selfconfig.c b/oobs/oobs-selfconfig.c
index 9b4754c..84664ea 100644
--- a/oobs/oobs-selfconfig.c
+++ b/oobs/oobs-selfconfig.c
@@ -225,9 +225,14 @@ oobs_self_config_get_update_message (OobsObject *object)
OobsObject*
oobs_self_config_get (void)
{
- return g_object_new (OOBS_TYPE_SELF_CONFIG,
- "remote-object", SELF_CONFIG_REMOTE_OBJECT,
- NULL);
+ static OobsObject *the_object = NULL;
+
+ if (!the_object)
+ the_object = g_object_new (OOBS_TYPE_SELF_CONFIG,
+ "remote-object", SELF_CONFIG_REMOTE_OBJECT,
+ NULL);
+
+ return the_object;
}
/**
diff --git a/oobs/oobs-servicesconfig.c b/oobs/oobs-servicesconfig.c
index 790fa90..c24e204 100644
--- a/oobs/oobs-servicesconfig.c
+++ b/oobs/oobs-servicesconfig.c
@@ -418,9 +418,14 @@ oobs_services_config_commit (OobsObject *object)
OobsObject*
oobs_services_config_get (void)
{
- return g_object_new (OOBS_TYPE_SERVICES_CONFIG,
- "remote-object", SERVICES_CONFIG_REMOTE_OBJECT,
- NULL);
+ static OobsObject *the_object = NULL;
+
+ if (!the_object)
+ the_object = g_object_new (OOBS_TYPE_SERVICES_CONFIG,
+ "remote-object", SERVICES_CONFIG_REMOTE_OBJECT,
+ NULL);
+
+ return the_object;
}
/**
diff --git a/oobs/oobs-smbconfig.c b/oobs/oobs-smbconfig.c
index 0941785..25aa242 100644
--- a/oobs/oobs-smbconfig.c
+++ b/oobs/oobs-smbconfig.c
@@ -456,9 +456,14 @@ oobs_smb_config_commit (OobsObject *object)
OobsObject*
oobs_smb_config_get (void)
{
- return g_object_new (OOBS_TYPE_SMB_CONFIG,
- "remote-object", SMB_CONFIG_REMOTE_OBJECT,
- NULL);
+ static OobsObject *the_object = NULL;
+
+ if (!the_object)
+ the_object = g_object_new (OOBS_TYPE_SMB_CONFIG,
+ "remote-object", SMB_CONFIG_REMOTE_OBJECT,
+ NULL);
+
+ return the_object;
}
/**
diff --git a/oobs/oobs-timeconfig.c b/oobs/oobs-timeconfig.c
index b6a8bd0..708dbf7 100644
--- a/oobs/oobs-timeconfig.c
+++ b/oobs/oobs-timeconfig.c
@@ -274,9 +274,14 @@ oobs_time_config_commit (OobsObject *object)
OobsObject*
oobs_time_config_get (void)
{
- return g_object_new (OOBS_TYPE_TIME_CONFIG,
- "remote-object", TIME_CONFIG_REMOTE_OBJECT,
- NULL);
+ static OobsObject *the_object = NULL;
+
+ if (!the_object)
+ the_object = g_object_new (OOBS_TYPE_TIME_CONFIG,
+ "remote-object", TIME_CONFIG_REMOTE_OBJECT,
+ NULL);
+
+ return the_object;
}
static gboolean
diff --git a/oobs/oobs-usersconfig.c b/oobs/oobs-usersconfig.c
index 261a5ba..0790da6 100644
--- a/oobs/oobs-usersconfig.c
+++ b/oobs/oobs-usersconfig.c
@@ -420,9 +420,14 @@ oobs_users_config_commit (OobsObject *object)
OobsObject*
oobs_users_config_get (void)
{
- return g_object_new (OOBS_TYPE_USERS_CONFIG,
- "remote-object", USERS_CONFIG_REMOTE_OBJECT,
- NULL);
+ static OobsObject *the_object = NULL;
+
+ if (!the_object)
+ the_object = g_object_new (OOBS_TYPE_USERS_CONFIG,
+ "remote-object", USERS_CONFIG_REMOTE_OBJECT,
+ NULL);
+
+ return the_object;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]