gtkstylecontext: guard against gtk_css_widget_node_get_widget() returning NULL in...
authorChristoph Reiter <creiter@src.gnome.org>
Mon, 19 Mar 2018 17:21:25 +0000 (18:21 +0100)
committerChristoph Reiter <creiter@src.gnome.org>
Tue, 20 Mar 2018 15:02:51 +0000 (16:02 +0100)
When the widget gets finalized it clears the widgetnode and gtk_css_widget_node_get_widget
returns NULL. Guard against gtk_css_widget_node_get_widget() returning NULL like in other
places.

See https://gitlab.gnome.org/GNOME/pygobject/issues/28#note_82862

gtk/gtkstylecontext.c

index 16897067d06d580cd2f1945bf58f579d84152d38..5ea19b3d7b17cfe43294ea02634b3268e0c29ff1 100644 (file)
@@ -170,7 +170,11 @@ gtk_style_context_real_changed (GtkStyleContext *context)
   GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
 
   if (GTK_IS_CSS_WIDGET_NODE (priv->cssnode))
-    _gtk_widget_style_context_invalidated (gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (priv->cssnode)));
+    {
+      GtkWidget *widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (priv->cssnode));
+      if (widget != NULL)
+        _gtk_widget_style_context_invalidated (widget);
+    }
 }
 
 static void