Merge branch 'issue2780' into 'gtk-3-24'

cssnode: Bail out nicely if there is no settings

See merge request GNOME/gtk!2646
This commit is contained in:
Matthias Clasen 2020-09-30 15:05:52 +00:00
commit c4c00461fe
3 changed files with 13 additions and 2 deletions

View File

@ -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

View File

@ -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);

View File

@ -1843,12 +1843,13 @@ GtkStyleCascade *
_gtk_settings_get_style_cascade (GtkSettings *settings,
gint scale)
{
GtkSettingsPrivate *priv = settings->priv;
GtkSettingsPrivate *priv;
GtkStyleCascade *new_cascade;
GSList *list;
g_return_val_if_fail (GTK_IS_SETTINGS (settings), NULL);
priv = settings->priv;
for (list = priv->style_cascades; list; list = list->next)
{
if (_gtk_style_cascade_get_scale (list->data) == scale)