From 9e4af0b746dddcd93981a2434cb351d8efb54bed Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 4 Jul 2013 12:54:59 +0200 Subject: [PATCH] widget: Don't crash if setting alpha on non-realized widget. https://bugzilla.gnome.org/show_bug.cgi?id=703154 --- gtk/gtkwidget.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index b5844e869e..d22b00c190 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -4999,6 +4999,10 @@ gtk_widget_realize (GtkWidget *widget) _gtk_widget_enable_device_events (widget); gtk_widget_update_devices_mask (widget, TRUE); + if (gtk_widget_is_toplevel (widget)) + gdk_window_set_opacity (priv->window, + priv->alpha / 255.0); + if (priv->context) gtk_style_context_set_scale (priv->context, gtk_widget_get_scale_factor (widget)); gtk_widget_connect_frame_clock (widget, @@ -14953,12 +14957,14 @@ gtk_widget_update_alpha (GtkWidget *widget) priv->alpha = alpha; - if (gtk_widget_is_toplevel (widget)) - gdk_window_set_opacity (priv->window, - priv->alpha / 255.0); - if (gtk_widget_get_realized (widget)) - gtk_widget_queue_draw (widget); + { + if (gtk_widget_is_toplevel (widget)) + gdk_window_set_opacity (priv->window, + priv->alpha / 255.0); + + gtk_widget_queue_draw (widget); + } } static void