From 2f9058621c5dfa8e3f7780731072e593898c3db8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Sep 2014 15:56:38 -0500 Subject: Setting up default referencing --- src/im-accounts-service.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/im-accounts-service.c b/src/im-accounts-service.c index 6fc2922..dc18d1b 100644 --- a/src/im-accounts-service.c +++ b/src/im-accounts-service.c @@ -76,9 +76,18 @@ im_accounts_service_finalize (GObject *object) G_OBJECT_CLASS (im_accounts_service_parent_class)->finalize (object); } +/* Not the most testable way to do this but, it is a less invasive one, and we'll + probably restructure this codebase soonish */ +/* Gets an account service wrapper reference, so then it can be free'd */ ImAccountsService * im_accounts_service_ref_default (void) { - - return NULL; + static ImAccountsService * as = NULL; + if (as == NULL) { + as = IM_ACCOUNTS_SERVICE(g_object_new(IM_ACCOUNTS_SERVICE_TYPE, NULL)); + g_object_add_weak_pointer(G_OBJECT(as), (gpointer *)&as); + return as; + } + + return g_object_ref(as); } -- cgit v1.2.3