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
This commit is contained in:
Rui Matos 2011-10-22 17:38:29 +01:00
parent 5c4f2ef0c1
commit d56484f6ed

View File

@ -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);
@ -632,6 +633,14 @@ maybe_update_shape (GtkTooltip *tooltip)
cairo_region_destroy (region);
}
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)