[gnome-control-center/gnome-3-36] user-panel: Pass a cancellable to the fingerprint operations



commit 7d133b8ba12c2b95720ebb6c5489be9df71dec22
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Thu Mar 26 06:44:55 2020 +0100

    user-panel: Pass a cancellable to the fingerprint operations
    
    And cancel it when changing user and on disposition

 panels/user-accounts/cc-user-panel.c         | 13 +++++++++++--
 panels/user-accounts/um-fingerprint-dialog.c | 15 ++++++++++++---
 2 files changed, 23 insertions(+), 5 deletions(-)
---
diff --git a/panels/user-accounts/cc-user-panel.c b/panels/user-accounts/cc-user-panel.c
index a1e00f79d..09ab8c47a 100644
--- a/panels/user-accounts/cc-user-panel.c
+++ b/panels/user-accounts/cc-user-panel.c
@@ -103,6 +103,8 @@ struct _CcUserPanel {
 
         CcAvatarChooser *avatar_chooser;
 
+        GCancellable *fingerprint_cancellable;
+
         gint other_accounts;
 };
 
@@ -178,6 +180,9 @@ set_selected_user (CcUserPanel *self, CcCarouselItem *item)
         g_set_object (&self->selected_user,
                       act_user_manager_get_user_by_id (self->um, uid));
 
+        g_cancellable_cancel (self->fingerprint_cancellable);
+        g_clear_object (&self->fingerprint_cancellable);
+
         if (self->selected_user != NULL) {
                 show_user (self->selected_user, self);
         }
@@ -855,9 +860,10 @@ show_user (ActUser *user, CcUserPanel *self)
 
         gtk_widget_set_visible (GTK_WIDGET (self->fingerprint_row), FALSE);
         if (show) {
+                self->fingerprint_cancellable = g_cancellable_new ();
                 set_fingerprint_row (GTK_WIDGET (self->fingerprint_row),
                                      self->fingerprint_state_label,
-                                     NULL);
+                                     self->fingerprint_cancellable);
         }
 
         /* Autologin: show when local account */
@@ -1092,7 +1098,7 @@ change_fingerprint (CcUserPanel *self)
                                     GTK_WIDGET (self->fingerprint_row),
                                     self->fingerprint_state_label,
                                     user,
-                                    NULL);
+                                    self->fingerprint_cancellable);
 }
 
 static void
@@ -1487,6 +1493,9 @@ cc_user_panel_dispose (GObject *object)
 
         g_clear_object (&self->login_screen_settings);
 
+        g_cancellable_cancel (self->fingerprint_cancellable);
+        g_clear_object (&self->fingerprint_cancellable);
+
         g_clear_pointer ((GtkWidget **)&self->language_chooser, gtk_widget_destroy);
         g_clear_object (&self->permission);
         G_OBJECT_CLASS (cc_user_panel_parent_class)->dispose (object);
diff --git a/panels/user-accounts/um-fingerprint-dialog.c b/panels/user-accounts/um-fingerprint-dialog.c
index dfc5503a7..d27aa3b4b 100644
--- a/panels/user-accounts/um-fingerprint-dialog.c
+++ b/panels/user-accounts/um-fingerprint-dialog.c
@@ -71,7 +71,10 @@ ensure_manager (GCancellable *cancellable)
 
         connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, cancellable, &error);
         if (connection == NULL) {
-                g_warning ("Failed to connect to session bus: %s", error->message);
+                if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+                        g_warning ("Failed to connect to session bus: %s",
+                                   error->message);
+                }
                 g_error_free (error);
                 return;
         }
@@ -85,7 +88,10 @@ ensure_manager (GCancellable *cancellable)
                                          cancellable,
                                          &error);
         if (manager == NULL) {
-                g_warning ("Failed to create fingerprint manager proxy: %s", error->message);
+                if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+                        g_warning ("Failed to create fingerprint manager proxy: %s",
+                                   error->message);
+                }
                 g_error_free (error);
         }
 }
@@ -125,7 +131,10 @@ get_first_device (GCancellable *cancellable)
                                         cancellable,
                                         &error);
         if (device == NULL) {
-                g_warning ("Failed to create fingerprint device proxy: %s", error->message);
+                if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+                        g_warning ("Failed to create fingerprint device proxy: %s",
+                                   error->message);
+                }
                 g_error_free (error);
         }
 


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