[gnome-control-center/wip/oholy/password-dialog-crashes: 6/6] user-accounts: Fix password dialog crashes



commit 29367abbb04e556eef6e57a69015fb4d02e9196f
Author: Ondrej Holy <oholy redhat com>
Date:   Fri Nov 8 16:10:47 2019 +0100

    user-accounts: Fix password dialog crashes
    
    Currently, the password_entry_timeout() callback can be called even after
    the dialog disposal, which leads to segfaults. This is because the
    corresponding source ids can be cleared in some cases without removing
    the sources. Let's prevent direct calls of password_entry_timeout()
    without destroying the source ids in order to fix this issue.
    
    Fixes: https://gitlab.gnome.org/GNOME/gnome-control-center/issues/760

 panels/user-accounts/cc-password-dialog.c  | 6 +++++-
 panels/user-accounts/cc-password-dialog.ui | 6 +++---
 2 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/panels/user-accounts/cc-password-dialog.c b/panels/user-accounts/cc-password-dialog.c
index 9476a8be5..b199999c0 100644
--- a/panels/user-accounts/cc-password-dialog.c
+++ b/panels/user-accounts/cc-password-dialog.c
@@ -336,6 +336,11 @@ password_entry_key_press_cb (CcPasswordDialog *self,
 {
         GdkEventKey *key = (GdkEventKey *)event;
 
+        if (self->password_entry_timeout_id != 0) {
+                g_source_remove (self->password_entry_timeout_id);
+                self->password_entry_timeout_id = 0;
+        }
+
         if (key->keyval == GDK_KEY_Tab)
                password_entry_timeout (self);
 
@@ -476,7 +481,6 @@ cc_password_dialog_class_init (CcPasswordDialogClass *klass)
         gtk_widget_class_bind_template_callback (widget_class, password_entry_focus_out_cb);
         gtk_widget_class_bind_template_callback (widget_class, password_entry_icon_press_cb);
         gtk_widget_class_bind_template_callback (widget_class, password_entry_key_press_cb);
-        gtk_widget_class_bind_template_callback (widget_class, password_entry_timeout);
         gtk_widget_class_bind_template_callback (widget_class, verify_entry_changed);
 }
 
diff --git a/panels/user-accounts/cc-password-dialog.ui b/panels/user-accounts/cc-password-dialog.ui
index f19d490e5..bfcc7585b 100644
--- a/panels/user-accounts/cc-password-dialog.ui
+++ b/panels/user-accounts/cc-password-dialog.ui
@@ -81,7 +81,7 @@
                     <property name="activates_default">True</property>
                     <property name="input_purpose">password</property>
                     <signal name="notify::text" handler="verify_entry_changed" object="CcPasswordDialog" 
swapped="yes"/>
-                    <signal name="activate" handler="password_entry_timeout" object="CcPasswordDialog" 
swapped="yes"/>
+                    <signal name="activate" handler="password_entry_focus_out_cb" object="CcPasswordDialog" 
swapped="yes"/>
                     <signal name="focus-out-event" handler="password_entry_focus_out_cb" after="yes" 
object="CcPasswordDialog" swapped="yes"/>
                   </object>
                   <packing>
@@ -181,7 +181,7 @@
                     <property name="activates_default">True</property>
                     <property name="input_purpose">password</property>
                     <signal name="notify::text" handler="password_entry_changed" object="CcPasswordDialog" 
swapped="yes"/>
-                    <signal name="activate" handler="password_entry_timeout" object="CcPasswordDialog" 
swapped="yes"/>
+                    <signal name="activate" handler="password_entry_focus_out_cb" object="CcPasswordDialog" 
swapped="yes"/>
                     <signal name="focus-out-event" handler="password_entry_focus_out_cb" after="yes" 
object="CcPasswordDialog" swapped="yes"/>
                     <signal name="key-press-event" handler="password_entry_key_press_cb" 
object="CcPasswordDialog" swapped="yes"/>
                     <signal name="icon-press" handler="password_entry_icon_press_cb" 
object="CcPasswordDialog" swapped="yes"/>
@@ -237,7 +237,7 @@
                     <property name="margin_bottom">12</property>
                     <property name="input_purpose">password</property>
                     <signal name="notify::text" handler="old_password_entry_changed" 
object="CcPasswordDialog" swapped="yes"/>
-                    <signal name="activate" handler="password_entry_timeout" object="CcPasswordDialog" 
swapped="yes"/>
+                    <signal name="activate" handler="old_password_entry_focus_out_cb" 
object="CcPasswordDialog" swapped="yes"/>
                     <signal name="focus-out-event" handler="old_password_entry_focus_out_cb" after="yes" 
object="CcPasswordDialog" swapped="yes"/>
                   </object>
                   <packing>


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