From f84df976a7f9aea5e9311ab53745f9c127b5a590 Mon Sep 17 00:00:00 2001 From: Kristian Rietveld Date: Sat, 22 Aug 2009 23:21:44 +0200 Subject: [PATCH] Bug 478519 - GtkTooltip segfaults on NULL gdk-display-current-tooltip Make the tooltip code a bit more robust for a case that only occurs when GTK+ is used from a language binding. It looks like this case appears because the memory management / ref counting is handled differently in some of the language bindings. Instead of asserting, we will fail silently. Also fix a think-o in gtk_tooltip_start_delay(). Patch from O. Andrieu. --- gtk/gtktooltip.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c index 77e47772cd..5ec6656a78 100644 --- a/gtk/gtktooltip.c +++ b/gtk/gtktooltip.c @@ -945,8 +945,6 @@ gtk_tooltip_show_tooltip (GdkDisplay *display) g_object_get (tooltip_widget, "has-tooltip", &has_tooltip, NULL); - g_assert (tooltip != NULL); - return_value = gtk_tooltip_run_requery (&tooltip_widget, tooltip, &x, &y); if (!return_value) return; @@ -1048,11 +1046,17 @@ tooltip_popup_timeout (gpointer data) GtkTooltip *tooltip; display = GDK_DISPLAY_OBJECT (data); + tooltip = g_object_get_data (G_OBJECT (display), + "gdk-display-current-tooltip"); + + /* This usually does not happen. However, it does occur in language + * bindings were reference counting of objects behaves differently. + */ + if (!tooltip) + return FALSE; gtk_tooltip_show_tooltip (display); - tooltip = g_object_get_data (G_OBJECT (display), - "gdk-display-current-tooltip"); tooltip->timeout_id = 0; return FALSE; @@ -1068,7 +1072,7 @@ gtk_tooltip_start_delay (GdkDisplay *display) tooltip = g_object_get_data (G_OBJECT (display), "gdk-display-current-tooltip"); - if (tooltip && GTK_TOOLTIP_VISIBLE (tooltip)) + if (!tooltip || GTK_TOOLTIP_VISIBLE (tooltip)) return; if (tooltip->timeout_id)