[gnome-control-center/user-accounts-fingerprint-disconnect-devices-on-dialog-closing] user-accounts: Disconnect devices when closing dialog




commit 95b8f5a02b16254dad1868822019f6d99d58350b
Author: Felipe Borges <felipeborges gnome org>
Date:   Wed Sep 14 11:47:59 2022 +0200

    user-accounts: Disconnect devices when closing dialog
    
    Otherwise when users close and reopen the window they will face a
    “Failed to claim fingerprint device Synoptics Sensors: the device is
    already claimed by another process” error message.
    
    Fixes #1983

 panels/user-accounts/cc-fingerprint-dialog.c  | 46 +++++++++++----------------
 panels/user-accounts/cc-fingerprint-dialog.ui |  1 +
 2 files changed, 19 insertions(+), 28 deletions(-)
---
diff --git a/panels/user-accounts/cc-fingerprint-dialog.c b/panels/user-accounts/cc-fingerprint-dialog.c
index 401c369f4..6d486deb5 100644
--- a/panels/user-accounts/cc-fingerprint-dialog.c
+++ b/panels/user-accounts/cc-fingerprint-dialog.c
@@ -275,32 +275,6 @@ disconnect_device_signals (CcFingerprintDialog *self)
     }
 }
 
-static void
-cc_fingerprint_dialog_dispose (GObject *object)
-{
-  CcFingerprintDialog *self = CC_FINGERPRINT_DIALOG (object);
-
-  g_clear_handle_id (&self->enroll_stage_passed_id, g_source_remove);
-
-  if (self->device && (self->dialog_state & DIALOG_STATE_DEVICE_CLAIMED))
-    {
-      disconnect_device_signals (self);
-
-      if (self->dialog_state & DIALOG_STATE_DEVICE_ENROLLING)
-        cc_fprintd_device_call_enroll_stop_sync (self->device, NULL, NULL);
-      cc_fprintd_device_call_release (self->device, NULL, NULL, NULL);
-    }
-
-  g_clear_object (&self->manager);
-  g_clear_object (&self->device);
-  g_clear_pointer (&self->enrolled_fingers, g_strfreev);
-
-  g_cancellable_cancel (self->cancellable);
-  g_clear_object (&self->cancellable);
-
-  G_OBJECT_CLASS (cc_fingerprint_dialog_parent_class)->dispose (object);
-}
-
 static void
 cc_fingerprint_dialog_get_property (GObject    *object,
                                     guint       prop_id,
@@ -1470,7 +1444,24 @@ static void
 fingerprint_dialog_delete_cb (CcFingerprintDialog *self)
 {
   cc_fingerprint_manager_update_state (self->manager, NULL, NULL);
-  gtk_window_destroy (GTK_WINDOW (self));
+
+  g_clear_handle_id (&self->enroll_stage_passed_id, g_source_remove);
+
+  if (self->device && (self->dialog_state & DIALOG_STATE_DEVICE_CLAIMED))
+    {
+      disconnect_device_signals (self);
+
+      if (self->dialog_state & DIALOG_STATE_DEVICE_ENROLLING)
+        cc_fprintd_device_call_enroll_stop_sync (self->device, NULL, NULL);
+      cc_fprintd_device_call_release (self->device, NULL, NULL, NULL);
+    }
+
+  g_clear_object (&self->manager);
+  g_clear_object (&self->device);
+  g_clear_pointer (&self->enrolled_fingers, g_strfreev);
+
+  g_cancellable_cancel (self->cancellable);
+  g_clear_object (&self->cancellable);
 }
 
 static void
@@ -1483,7 +1474,6 @@ cc_fingerprint_dialog_class_init (CcFingerprintDialogClass *klass)
     "/org/gnome/control-center/user-accounts/cc-fingerprint-dialog.ui");
 
   object_class->constructed = cc_fingerprint_dialog_constructed;
-  object_class->dispose = cc_fingerprint_dialog_dispose;
   object_class->get_property = cc_fingerprint_dialog_get_property;
   object_class->set_property = cc_fingerprint_dialog_set_property;
 
diff --git a/panels/user-accounts/cc-fingerprint-dialog.ui b/panels/user-accounts/cc-fingerprint-dialog.ui
index 9c74f84b6..dc30f90e7 100644
--- a/panels/user-accounts/cc-fingerprint-dialog.ui
+++ b/panels/user-accounts/cc-fingerprint-dialog.ui
@@ -11,6 +11,7 @@
     <property name="default-height">400</property>
     <property name="modal">True</property>
     <property name="hide-on-close">True</property>
+    <signal name="close-request" handler="fingerprint_dialog_delete_cb" object="CcFingerprintDialog" 
swapped="yes" />
     <child type="titlebar">
       <object class="AdwHeaderBar" id="titlebar">
         <property name="show-end-title-buttons">True</property>


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