entry: Avoid criticals in dispose
authorMatthias Clasen <mclasen@redhat.com>
Tue, 4 Feb 2020 21:15:32 +0000 (22:15 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 5 Feb 2020 06:01:47 +0000 (01:01 -0500)
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

index 921a96951bebea70028801c119746ad9264abf74..77d2dd3bbc00debc486e037268fc4e04d88b55be 100644 (file)
@@ -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);