diff --git a/ChangeLog b/ChangeLog index 0cb397c02f..114d9bb85c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2007-07-23 Matthias Clasen + * gtk/gtktooltip.c (gtk_tooltip_set_custom): Protect against + recursion via gtk_container_remove(). (#459561, Christian Persch) + (gtk_tooltip_window_hide): Simplify. + * tests/testtooltips.c: Add code to test gtk_tooltip_set_custom() 2007-07-23 Christian Persch diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c index d60829df31..2d60b7c65d 100644 --- a/gtk/gtktooltip.c +++ b/gtk/gtktooltip.c @@ -314,9 +314,14 @@ gtk_tooltip_set_custom (GtkTooltip *tooltip, if (tooltip->custom_widget) { - gtk_container_remove (GTK_CONTAINER (tooltip->box), - tooltip->custom_widget); - g_object_unref (tooltip->custom_widget); + GtkWidget *custom = tooltip->custom_widget; + /* Note: We must reset tooltip->custom_widget first, + * since gtk_container_remove() will recurse into + * gtk_tooltip_set_custom() + */ + tooltip->custom_widget = NULL; + gtk_container_remove (GTK_CONTAINER (tooltip->box), custom); + g_object_unref (custom); } if (custom_widget) @@ -326,8 +331,6 @@ gtk_tooltip_set_custom (GtkTooltip *tooltip, gtk_container_add (GTK_CONTAINER (tooltip->box), custom_widget); gtk_widget_show (custom_widget); } - else - tooltip->custom_widget = NULL; } /** @@ -427,8 +430,7 @@ gtk_tooltip_window_hide (GtkWidget *widget, { GtkTooltip *tooltip = GTK_TOOLTIP (user_data); - if (tooltip->custom_widget) - gtk_tooltip_set_custom (tooltip, NULL); + gtk_tooltip_set_custom (tooltip, NULL); } /* event handling, etc */