[gtk+] widget: Don't crash if setting alpha on non-realized widget.



commit 9e4af0b746dddcd93981a2434cb351d8efb54bed
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Jul 4 12:54:59 2013 +0200

    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 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index b5844e8..d22b00c 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


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