[gnome-photos/wip/rishi/collection: 3/44] source-manager: Style fix



commit df63b535b945a0b406f6d0d3f912451b0ea39687
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Feb 2 03:23:47 2018 +0100

    source-manager: Style fix
    
    Not only does this match the pattern used elsewhere in the codebase,
    it will also be useful when tracking GMounts because a failure to
    create a GoaClient doesn't mean that that the GMounts can't be read.
    
    https://gitlab.gnome.org/GNOME/gnome-photos/issues/29

 src/photos-source-manager.c | 40 +++++++++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 17 deletions(-)
---
diff --git a/src/photos-source-manager.c b/src/photos-source-manager.c
index 9d76b625..738372ef 100644
--- a/src/photos-source-manager.c
+++ b/src/photos-source-manager.c
@@ -198,7 +198,7 @@ static void
 photos_source_manager_goa_client (GObject *source_object, GAsyncResult *res, gpointer user_data)
 {
   PhotosSourceManager *self;
-  GoaClient *client;
+  g_autoptr (GoaClient) client = NULL;
 
   {
     g_autoptr (GError) error = NULL;
@@ -206,30 +206,36 @@ photos_source_manager_goa_client (GObject *source_object, GAsyncResult *res, gpo
     client = goa_client_new_finish (res, &error);
     if (error != NULL)
       {
-        if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
-          g_warning ("Unable to create GoaClient: %s", error->message);
+        if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+          goto out;
 
-        return;
+        g_warning ("Unable to create GoaClient: %s", error->message);
       }
   }
 
   self = PHOTOS_SOURCE_MANAGER (user_data);
 
-  self->client = client;
-  g_signal_connect_swapped (self->client,
-                            "account-added",
-                            G_CALLBACK (photos_source_manager_refresh_accounts),
-                            self);
-  g_signal_connect_swapped (self->client,
-                            "account-changed",
-                            G_CALLBACK (photos_source_manager_refresh_accounts),
-                            self);
-  g_signal_connect_swapped (self->client,
-                            "account-removed",
-                            G_CALLBACK (photos_source_manager_refresh_accounts),
-                            self);
+  if (client != NULL)
+    {
+      self->client = g_object_ref (client);
+      g_signal_connect_swapped (self->client,
+                                "account-added",
+                                G_CALLBACK (photos_source_manager_refresh_accounts),
+                                self);
+      g_signal_connect_swapped (self->client,
+                                "account-changed",
+                                G_CALLBACK (photos_source_manager_refresh_accounts),
+                                self);
+      g_signal_connect_swapped (self->client,
+                                "account-removed",
+                                G_CALLBACK (photos_source_manager_refresh_accounts),
+                                self);
+    }
 
   photos_source_manager_refresh_accounts (self);
+
+ out:
+  return;
 }
 
 


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