mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 21:51:08 +00:00
css: Improve error reporting for variables
Emit errors for all the variables that were being expanded if an error occurs while parsing a property value at compute time. Include the variables that are being expanded in the error message.
This commit is contained in:
parent
b914869715
commit
c45815c217
@ -209,15 +209,39 @@ parser_error (GtkCssParser *parser,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkStyleProvider *provider = user_data;
|
||||
GtkCssSection *section;
|
||||
GError *new_error = NULL;
|
||||
GtkCssVariableValue **vars;
|
||||
char **names;
|
||||
gsize n_vars;
|
||||
|
||||
section = gtk_css_section_new (gtk_css_parser_get_file (parser),
|
||||
start,
|
||||
end);
|
||||
gtk_css_parser_get_expanding_variables (parser, &vars, &names, &n_vars);
|
||||
|
||||
gtk_style_provider_emit_error (provider, section, (GError *) error);
|
||||
if (n_vars > 0)
|
||||
{
|
||||
for (int i = 0; i < n_vars; i++)
|
||||
{
|
||||
if (names[i + 1])
|
||||
g_set_error (&new_error,
|
||||
GTK_CSS_PARSER_ERROR, GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE,
|
||||
"While expanding %s: %s", names[i + 1], error->message);
|
||||
else
|
||||
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);
|
||||
g_clear_error (&new_error);
|
||||
}
|
||||
|
||||
gtk_css_section_unref (section);
|
||||
for (int i = 0; i < n_vars; i++)
|
||||
{
|
||||
if (vars[i])
|
||||
gtk_css_variable_value_unref (vars[i]);
|
||||
g_free (names[i]);
|
||||
}
|
||||
|
||||
g_free (vars);
|
||||
g_free (names);
|
||||
}
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
|
Loading…
Reference in New Issue
Block a user