[gnome-photos/wip/rishi/share-point-google-g_auto] share-point-google: Use g_auto*




commit aa08274aab645f7a9a68748107c5ab5ed11d6223
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Aug 25 22:58:16 2020 +0200

    share-point-google: Use g_auto*
    
    https://gitlab.gnome.org/GNOME/gnome-photos/issues/77

 src/photos-share-point-google.c | 44 +++++++++++++++++------------------------
 1 file changed, 18 insertions(+), 26 deletions(-)
---
diff --git a/src/photos-share-point-google.c b/src/photos-share-point-google.c
index ee55dd09..fcd23435 100644
--- a/src/photos-share-point-google.c
+++ b/src/photos-share-point-google.c
@@ -1,6 +1,6 @@
 /*
  * Photos - access, organize and share your photos on GNOME
- * Copyright © 2016 – 2019 Red Hat, Inc.
+ * Copyright © 2016 – 2020 Red Hat, Inc.
  * Copyright © 2016 Umang Jain
  *
  * This program is free software: you can redistribute it and/or modify
@@ -112,7 +112,7 @@ static void
 photos_share_point_google_share_insert_shared_content (GObject *source_object, GAsyncResult *res, gpointer 
user_data)
 {
   GError *error;
-  GTask *task = G_TASK (user_data);
+  g_autoptr (GTask) task = G_TASK (user_data);
   GomMiner *miner = GOM_MINER (source_object);
 
   error = NULL;
@@ -125,7 +125,7 @@ photos_share_point_google_share_insert_shared_content (GObject *source_object, G
   g_task_return_boolean (task, TRUE);
 
  out:
-  g_object_unref (task);
+  return;
 }
 
 
@@ -179,7 +179,7 @@ photos_share_point_google_share_metadata_add_shared (GObject *source_object, GAs
 {
   PhotosSharePointGoogle *self;
   GError *error;
-  GTask *task = G_TASK (user_data);
+  g_autoptr (GTask) task = G_TASK (user_data);
   PhotosBaseItem *item = PHOTOS_BASE_ITEM (source_object);
   PhotosSharePointGoogleShareData *data;
 
@@ -207,7 +207,7 @@ photos_share_point_google_share_metadata_add_shared (GObject *source_object, GAs
     photos_share_point_google_share_metadata_add_shared_second (self, g_object_ref (task));
 
  out:
-  g_object_unref (task);
+  return;
 }
 
 
@@ -216,10 +216,10 @@ photos_share_point_google_share_wait_for_changes (GObject *source_object, GAsync
 {
   PhotosSharePointGoogle *self;
   GError *error;
-  GTask *task = G_TASK (user_data);
+  g_autoptr (GTask) task = G_TASK (user_data);
   PhotosItemManager *item_mngr = PHOTOS_ITEM_MANAGER (source_object);
   PhotosSharePointGoogleShareData *data;
-  gchar *item_id_after_changes = NULL;
+  g_autofree gchar *item_id_after_changes = NULL;
 
   self = PHOTOS_SHARE_POINT_GOOGLE (g_task_get_source_object (task));
   data = (PhotosSharePointGoogleShareData *) g_task_get_task_data (task);
@@ -242,16 +242,14 @@ photos_share_point_google_share_wait_for_changes (GObject *source_object, GAsync
     }
 
   g_assert_null (data->item_id_after_changes);
-  data->item_id_after_changes = item_id_after_changes;
-  item_id_after_changes = NULL;
+  data->item_id_after_changes = g_steal_pointer (&item_id_after_changes);
 
   data->pending_async_calls--;
   if (data->pending_async_calls == 0)
     photos_share_point_google_share_metadata_add_shared_second (self, g_object_ref (task));
 
  out:
-  g_free (item_id_after_changes);
-  g_object_unref (task);
+  return;
 }
 
 
@@ -261,8 +259,8 @@ photos_share_point_google_share_save_to_stream (GObject *source_object, GAsyncRe
   PhotosSharePointGoogle *self;
   GCancellable *cancellable;
   GError *error;
-  GTask *task = G_TASK (user_data);
-  GDataPicasaWebFile *file_entry = NULL;
+  g_autoptr (GTask) task = G_TASK (user_data);
+  g_autoptr (GDataPicasaWebFile) file_entry = NULL;
   GoaAccount *account;
   GoaObject *object;
   PhotosBaseItem *item = PHOTOS_BASE_ITEM (source_object);
@@ -271,7 +269,7 @@ photos_share_point_google_share_save_to_stream (GObject *source_object, GAsyncRe
   const gchar *account_identity;
   const gchar *file_entry_id;
   const gchar *provider_type;
-  gchar *shared_identifier = NULL;
+  g_autofree gchar *shared_identifier = NULL;
 
   self = PHOTOS_SHARE_POINT_GOOGLE (g_task_get_source_object (task));
   cancellable = g_task_get_cancellable (task);
@@ -333,9 +331,7 @@ photos_share_point_google_share_save_to_stream (GObject *source_object, GAsyncRe
   data->pending_async_calls++;
 
  out:
-  g_clear_object (&file_entry);
-  g_object_unref (task);
-  g_free (shared_identifier);
+  return;
 }
 
 
@@ -347,10 +343,10 @@ photos_share_point_google_share_refresh_authorization (GObject *source_object,
   PhotosSharePointGoogle *self;
   GCancellable *cancellable;
   GError *error;
-  GTask *task = G_TASK (user_data);
+  g_autoptr (GTask) task = G_TASK (user_data);
   GDataAuthorizer *authorizer = GDATA_AUTHORIZER (source_object);
-  GDataPicasaWebFile *file_entry = NULL;
-  GDataUploadStream *stream = NULL;
+  g_autoptr (GDataPicasaWebFile) file_entry = NULL;
+  g_autoptr (GDataUploadStream) stream = NULL;
   PhotosSharePointGoogleShareData *data;
   const gchar *filename;
   const gchar *mime_type;
@@ -399,9 +395,7 @@ photos_share_point_google_share_refresh_authorization (GObject *source_object,
                                          g_object_ref (task));
 
  out:
-  g_clear_object (&file_entry);
-  g_clear_object (&stream);
-  g_object_unref (task);
+  return;
 }
 
 
@@ -413,7 +407,7 @@ photos_share_point_google_share_async (PhotosSharePoint *share_point,
                                        gpointer user_data)
 {
   PhotosSharePointGoogle *self = PHOTOS_SHARE_POINT_GOOGLE (share_point);
-  GTask *task;
+  g_autoptr (GTask) task = NULL;
   PhotosSharePointGoogleShareData *data;
 
   data = photos_share_point_google_share_data_new (item);
@@ -426,8 +420,6 @@ photos_share_point_google_share_async (PhotosSharePoint *share_point,
                                                 cancellable,
                                                 photos_share_point_google_share_refresh_authorization,
                                                 g_object_ref (task));
-
-  g_object_unref (task);
 }
 
 


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