From 005ea7a09d719894ec38f98ec622f0291571a93f Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 4 Feb 2020 22:15:32 +0100 Subject: [PATCH] entry: Avoid criticals in dispose The accessible gets properties of the entry, and resetting the entry icons triggers accessible change notification, so do that before we dismantle the entry too far to respond to a g_object_get () call. --- gtk/gtkentry.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 921a96951b..77d2dd3bbc 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -1288,6 +1288,11 @@ gtk_entry_dispose (GObject *object) GtkEntry *entry = GTK_ENTRY (object); GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry); + gtk_entry_set_icon_from_paintable (entry, GTK_ENTRY_ICON_PRIMARY, NULL); + gtk_entry_set_icon_tooltip_markup (entry, GTK_ENTRY_ICON_PRIMARY, NULL); + gtk_entry_set_icon_from_paintable (entry, GTK_ENTRY_ICON_SECONDARY, NULL); + gtk_entry_set_icon_tooltip_markup (entry, GTK_ENTRY_ICON_SECONDARY, NULL); + gtk_entry_set_completion (entry, NULL); if (priv->text) @@ -1299,11 +1304,6 @@ gtk_entry_dispose (GObject *object) g_clear_pointer (&priv->emoji_chooser, gtk_widget_unparent); - gtk_entry_set_icon_from_paintable (entry, GTK_ENTRY_ICON_PRIMARY, NULL); - gtk_entry_set_icon_tooltip_markup (entry, GTK_ENTRY_ICON_PRIMARY, NULL); - gtk_entry_set_icon_from_paintable (entry, GTK_ENTRY_ICON_SECONDARY, NULL); - gtk_entry_set_icon_tooltip_markup (entry, GTK_ENTRY_ICON_SECONDARY, NULL); - G_OBJECT_CLASS (gtk_entry_parent_class)->dispose (object); } @@ -2299,18 +2299,19 @@ gtk_entry_set_icon_from_paintable (GtkEntry *entry, GdkPaintable *paintable) { GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry); - EntryIconInfo *icon_info; g_return_if_fail (GTK_IS_ENTRY (entry)); g_return_if_fail (IS_VALID_ICON_POSITION (icon_pos)); - if ((icon_info = priv->icons[icon_pos]) == NULL) - icon_info = construct_icon_info (GTK_WIDGET (entry), icon_pos); - g_object_freeze_notify (G_OBJECT (entry)); if (paintable) { + EntryIconInfo *icon_info; + + if ((icon_info = priv->icons[icon_pos]) == NULL) + icon_info = construct_icon_info (GTK_WIDGET (entry), icon_pos); + g_object_ref (paintable); gtk_image_set_from_paintable (GTK_IMAGE (icon_info->widget), paintable);