[gtk+/gtk-2-16] Bug 478519 - GtkTooltip segfaults on NULL gdk-display-current-tooltip



commit bd612ac56bcbbabc683181a538b12ced6b76543e
Author: Kristian Rietveld <kris gtk org>
Date:   Sat Aug 22 23:21:44 2009 +0200

    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 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c
index af733b7..626384c 100644
--- a/gtk/gtktooltip.c
+++ b/gtk/gtktooltip.c
@@ -941,8 +941,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;
@@ -1044,11 +1042,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;
@@ -1064,7 +1068,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)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]