cssnode: Bail out nicely if there is no settings
On gdk_display_close(), the GtkSettings attached to the display are freed. Yet the gtk CSS code may still be called from the widget unparent, leading to a segfault. Check if the GtkSettings is not NULL and bail out nicely if not. Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2780
This commit is contained in:
@ -1432,6 +1432,7 @@ GtkStyleProviderPrivate *
|
||||
gtk_css_node_get_style_provider (GtkCssNode *cssnode)
|
||||
{
|
||||
GtkStyleProviderPrivate *result;
|
||||
GtkSettings *settings;
|
||||
|
||||
result = gtk_css_node_get_style_provider_or_null (cssnode);
|
||||
if (result)
|
||||
@ -1440,7 +1441,11 @@ gtk_css_node_get_style_provider (GtkCssNode *cssnode)
|
||||
if (cssnode->parent)
|
||||
return gtk_css_node_get_style_provider (cssnode->parent);
|
||||
|
||||
return GTK_STYLE_PROVIDER_PRIVATE (_gtk_settings_get_style_cascade (gtk_settings_get_default (), 1));
|
||||
settings = gtk_settings_get_default ();
|
||||
if (!settings)
|
||||
return NULL;
|
||||
|
||||
return GTK_STYLE_PROVIDER_PRIVATE (_gtk_settings_get_style_cascade (settings, 1));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -235,6 +235,7 @@ gtk_css_widget_node_get_style_provider (GtkCssNode *node)
|
||||
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
|
||||
GtkStyleContext *context;
|
||||
GtkStyleCascade *cascade;
|
||||
GtkSettings *settings;
|
||||
|
||||
if (widget_node->widget == NULL)
|
||||
return NULL;
|
||||
@ -243,6 +244,10 @@ gtk_css_widget_node_get_style_provider (GtkCssNode *node)
|
||||
if (context)
|
||||
return gtk_style_context_get_style_provider (context);
|
||||
|
||||
settings = gtk_widget_get_settings (widget_node->widget);
|
||||
if (!settings)
|
||||
return NULL;
|
||||
|
||||
cascade = _gtk_settings_get_style_cascade (gtk_widget_get_settings (widget_node->widget),
|
||||
gtk_widget_get_scale_factor (widget_node->widget));
|
||||
return GTK_STYLE_PROVIDER_PRIVATE (cascade);
|
||||
|
Reference in New Issue
Block a user