[gtk/gtk-3-22: 1/2] gtkstylecontext: guard against gtk_css_widget_node_get_widget() returning NULL in more places
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk-3-22: 1/2] gtkstylecontext: guard against gtk_css_widget_node_get_widget() returning NULL in more places
- Date: Tue, 20 Mar 2018 14:57:05 +0000 (UTC)
commit d65a4c2e0abeefb1e61e32a2da2c1e1ba9987817
Author: Christoph Reiter <creiter src gnome org>
Date: Mon Mar 19 18:21:25 2018 +0100
gtkstylecontext: guard against gtk_css_widget_node_get_widget() returning NULL in more places
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 | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 4ef6d574d6..2606815cb3 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -187,7 +187,11 @@ gtk_style_context_real_changed (GtkStyleContext *context)
GtkStyleContextPrivate *priv = context->priv;
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
@@ -522,7 +526,8 @@ gtk_style_context_push_state (GtkStyleContext *context,
{
GtkWidget *widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (root));
g_debug ("State %u for %s %p doesn't match state %u set via gtk_style_context_set_state ()",
- state, gtk_widget_get_name (widget), widget, gtk_css_node_get_state (priv->cssnode));
+ state, (widget == NULL) ? "(null)" : gtk_widget_get_name (widget),
+ widget, gtk_css_node_get_state (priv->cssnode));
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]