[gtk+] css: Fix segfault when GtkCssStyleChange is NULL on gtk_widget_real_style_updated()



commit e0ce028c88858b96aeda9e41734a39a3a04f705d
Author: Juan Pablo Ugarte <ugarte endlessm com>
Date:   Thu Dec 14 15:35:40 2017 -0300

    css: Fix segfault when GtkCssStyleChange is NULL on gtk_widget_real_style_updated()
    
    https://bugzilla.gnome.org/show_bug.cgi?id=791281

 gtk/gtkwidget.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 13f9cd5..174b64a 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -6891,11 +6891,15 @@ gtk_widget_real_state_flags_changed (GtkWidget     *widget,
 static void
 gtk_widget_real_style_updated (GtkWidget *widget)
 {
+  GtkCssStyleChange *change = NULL;
+
   gtk_widget_update_alpha (widget);
 
   if (widget->priv->context)
+    change = gtk_style_context_get_change (widget->priv->context);
+
+  if (change)
     {
-      GtkCssStyleChange *change = gtk_style_context_get_change (widget->priv->context);
       const gboolean has_text = gtk_widget_peek_pango_context (widget) != NULL;
 
       if (has_text && gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT))
@@ -6903,8 +6907,7 @@ gtk_widget_real_style_updated (GtkWidget *widget)
 
       if (widget->priv->anchored)
         {
-          if (change == NULL ||
-              gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE) ||
+          if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE) ||
               (has_text && gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT_SIZE)))
             {
               gtk_widget_queue_resize (widget);


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