[gnome-photos/wip/rishi/import-1: 2/6] source-manager: Style fix



commit 141fa82a2e26d59590713478db54b6fb6d9bdf42
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 | 44 +++++++++++++++++++++++++-------------------
 1 file changed, 25 insertions(+), 19 deletions(-)
---
diff --git a/src/photos-source-manager.c b/src/photos-source-manager.c
index 8596f76b..e24a0409 100644
--- a/src/photos-source-manager.c
+++ b/src/photos-source-manager.c
@@ -208,7 +208,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;
@@ -216,30 +216,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);
-
-  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]