[gnome-online-accounts/wip/rishi/kerberos: 5/11] goa_identity_manager_get_identity_finish should return a new ref



commit 0c87694ed1bb681f4cbe96bce116486fe306365c
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Aug 2 01:43:09 2016 +0200

    goa_identity_manager_get_identity_finish should return a new ref
    
    The vast majority, if not all, of *_finish functions out there transfer
    ownership of the return value to the caller. This also matches with the
    behaviour of new APIs like g_task_propagate_pointer. Therefore, let's
    make this change for the sake of consistency and making it easier to
    port to GTask.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=764157

 src/goaidentity/goaidentityservice.c         |    7 +++++--
 src/goaidentity/goakerberosidentitymanager.c |    2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/src/goaidentity/goaidentityservice.c b/src/goaidentity/goaidentityservice.c
index 80a4b72..1dba442 100644
--- a/src/goaidentity/goaidentityservice.c
+++ b/src/goaidentity/goaidentityservice.c
@@ -463,7 +463,7 @@ on_got_identity_for_sign_out (GoaIdentityManager *manager,
                               GSimpleAsyncResult *operation_result)
 {
   GError *error;
-  GoaIdentity *identity;
+  GoaIdentity *identity = NULL;
 
   error = NULL;
   identity = goa_identity_manager_get_identity_finish (manager, result, &error);
@@ -472,7 +472,7 @@ on_got_identity_for_sign_out (GoaIdentityManager *manager,
     {
       g_debug ("GoaIdentityService: Identity could not be signed out: %s",
                error->message);
-      return;
+      goto out;
     }
 
   g_object_set_data_full (G_OBJECT (operation_result),
@@ -487,6 +487,9 @@ on_got_identity_for_sign_out (GoaIdentityManager *manager,
                                           (GAsyncReadyCallback)
                                           on_identity_signed_out,
                                           operation_result);
+
+ out:
+  g_clear_object (&identity);
 }
 
 static gboolean
diff --git a/src/goaidentity/goakerberosidentitymanager.c b/src/goaidentity/goakerberosidentitymanager.c
index c3645cc..016786d 100644
--- a/src/goaidentity/goakerberosidentitymanager.c
+++ b/src/goaidentity/goakerberosidentitymanager.c
@@ -1108,7 +1108,7 @@ goa_kerberos_identity_manager_get_identity_finish (GoaIdentityManager  *self,
   identity =
     g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (result));
 
-  return identity;
+  return g_object_ref (identity);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]