Re: [PATCH] Make NMManager a singleton
- From: Dan Williams <dcbw redhat com>
- To: Sjoerd Simons <sjoerd simons collabora co uk>
- Cc: networkmanager-list gnome org
- Subject: Re: [PATCH] Make NMManager a singleton
- Date: Mon, 04 Aug 2008 18:27:13 -0400
On Mon, 2008-08-04 at 12:28 +0100, Sjoerd Simons wrote:
> Make NMManager a singleton.
svn3896
Thanks!
Dan
> Signed-off-by: Sjoerd Simons <sjoerd simons collabora co uk>
> ---
> src/NetworkManager.c | 2 +-
> src/nm-manager.c | 7 +++++--
> src/nm-manager.h | 2 +-
> 3 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/src/NetworkManager.c b/src/NetworkManager.c
> index f6651de..9468c94 100644
> --- a/src/NetworkManager.c
> +++ b/src/NetworkManager.c
> @@ -303,7 +303,7 @@ main (int argc, char *argv[])
> goto done;
> }
>
> - manager = nm_manager_new ();
> + manager = nm_manager_get ();
> if (manager == NULL) {
> nm_error ("Failed to initialize the network manager.");
> goto done;
> diff --git a/src/nm-manager.c b/src/nm-manager.c
> index 18b165a..0c497e8 100644
> --- a/src/nm-manager.c
> +++ b/src/nm-manager.c
> @@ -1353,11 +1353,14 @@ deferred_sync_devices (gpointer user_data)
> }
>
> NMManager *
> -nm_manager_new (void)
> +nm_manager_get (void)
> {
> - GObject *object;
> + static GObject *object = NULL;
> NMManagerPrivate *priv;
>
> + if (object != NULL)
> + return NM_MANAGER(g_object_ref(object));
> +
> object = g_object_new (NM_TYPE_MANAGER, NULL);
> priv = NM_MANAGER_GET_PRIVATE (object);
>
> diff --git a/src/nm-manager.h b/src/nm-manager.h
> index fb53bdd..fd74432 100644
> --- a/src/nm-manager.h
> +++ b/src/nm-manager.h
> @@ -52,7 +52,7 @@ typedef struct {
>
> GType nm_manager_get_type (void);
>
> -NMManager *nm_manager_new (void);
> +NMManager *nm_manager_get (void);
>
> /* Device handling */
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]