Merge branch 'ebassi/css-section-warning' into 'main'

css: Create a section if the variable does not have one

See merge request GNOME/gtk!7306
This commit is contained in:
Matthias Clasen 2024-05-29 14:01:55 +00:00
commit c14e167a11

View File

@ -220,6 +220,8 @@ parser_error (GtkCssParser *parser,
{
for (int i = 0; i < n_vars; i++)
{
GtkCssSection *section;
if (names[i + 1])
g_set_error (&new_error,
GTK_CSS_PARSER_ERROR, GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE,
@ -228,7 +230,15 @@ parser_error (GtkCssParser *parser,
g_set_error_literal (&new_error,
GTK_CSS_PARSER_ERROR, GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE,
error->message);
gtk_style_provider_emit_error (provider, vars[i]->section, new_error);
if (vars[i]->section == NULL)
section = gtk_css_section_new (gtk_css_parser_get_file (parser), start, end);
else
section = gtk_css_section_ref (vars[i]->section);
gtk_style_provider_emit_error (provider, section, new_error);
gtk_css_section_unref (section);
g_clear_error (&new_error);
}