From 53af41e2fa50ea23057b324ff222c86560924282 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 29 Jan 2023 22:37:51 -0500 Subject: [PATCH] passwordentry: Fix an asymmetry When connecting a signal in realize, we should disconnect in unrealize. Fixes: #5285 --- gtk/gtkpasswordentry.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/gtk/gtkpasswordentry.c b/gtk/gtkpasswordentry.c index 5fe1346dd6..b540a27fca 100644 --- a/gtk/gtkpasswordentry.c +++ b/gtk/gtkpasswordentry.c @@ -250,14 +250,25 @@ gtk_password_entry_realize (GtkWidget *widget) } } +static void +gtk_password_entry_unrealize (GtkWidget *widget) +{ + GtkPasswordEntry *entry = GTK_PASSWORD_ENTRY (widget); + + if (entry->keyboard) + { + g_signal_handlers_disconnect_by_func (entry->keyboard, caps_lock_state_changed, entry); + entry->keyboard = NULL; + } + + GTK_WIDGET_CLASS (gtk_password_entry_parent_class)->unrealize (widget); +} + static void gtk_password_entry_dispose (GObject *object) { GtkPasswordEntry *entry = GTK_PASSWORD_ENTRY (object); - if (entry->keyboard) - g_signal_handlers_disconnect_by_func (entry->keyboard, caps_lock_state_changed, entry); - if (entry->entry) gtk_editable_finish_delegate (GTK_EDITABLE (entry)); @@ -448,6 +459,7 @@ gtk_password_entry_class_init (GtkPasswordEntryClass *klass) object_class->set_property = gtk_password_entry_set_property; widget_class->realize = gtk_password_entry_realize; + widget_class->unrealize = gtk_password_entry_unrealize; widget_class->measure = gtk_password_entry_measure; widget_class->size_allocate = gtk_password_entry_size_allocate; widget_class->mnemonic_activate = gtk_password_entry_mnemonic_activate;