[gtk+] tooltip: only update shape if the window is realized



commit d56484f6ed010d020df5d1f09b330746cc894480
Author: Rui Matos <tiagomatos gmail com>
Date:   Sat Oct 22 17:38:29 2011 +0100

    tooltip: only update shape if the window is realized
    
    If we get a composited-changed signal before the tooltip is ever realized we
    have nothing to do.
    
    This actually prevents a segfault in maybe_update_shape() because calling
    gtk_widget_get_window() on a non-realized widget returns NULL.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=662467

 gtk/gtktooltip.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c
index 29f4630..2ca7748 100644
--- a/gtk/gtktooltip.c
+++ b/gtk/gtktooltip.c
@@ -159,7 +159,8 @@ static gboolean   gtk_tooltip_paint_window         (GtkTooltip      *tooltip,
                                                     cairo_t         *cr);
 static void       gtk_tooltip_realize_window       (GtkTooltip      *tooltip,
                                                     GtkWidget       *widget);
-static void       maybe_update_shape               (GtkTooltip      *tooltip);
+static void       gtk_tooltip_composited_changed   (GtkTooltip      *tooltip,
+                                                    GtkWidget       *widget);
 static void       gtk_tooltip_window_hide          (GtkWidget       *widget,
 						    gpointer         user_data);
 static void       gtk_tooltip_display_closed       (GdkDisplay      *display,
@@ -228,7 +229,7 @@ gtk_tooltip_init (GtkTooltip *tooltip)
   g_signal_connect_swapped (window, "realize",
                             G_CALLBACK (gtk_tooltip_realize_window), tooltip);
   g_signal_connect_swapped (window, "composited-changed",
-                            G_CALLBACK (maybe_update_shape), tooltip);
+                            G_CALLBACK (gtk_tooltip_composited_changed), tooltip);
 
   /* FIXME: don't hardcode the padding */
   box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
@@ -633,6 +634,14 @@ maybe_update_shape (GtkTooltip *tooltip)
 }
 
 static void
+gtk_tooltip_composited_changed (GtkTooltip *tooltip,
+                                GtkWidget  *widget)
+{
+  if (gtk_widget_get_realized (tooltip->window))
+    maybe_update_shape (tooltip);
+}
+
+static void
 gtk_tooltip_realize_window (GtkTooltip *tooltip,
                             GtkWidget *widget)
 {



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