mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-27 06:26:15 +01:00
Bug 623402 - schema compiler reports wrong line
Don't reuse the GMarkupParseContext in order to avoid inaccurate line number reports. Fix a memory leak, too.
This commit is contained in:
parent
7a44a2d223
commit
a941660873
@ -1552,14 +1552,9 @@ parse_gschema_files (gchar **files,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GMarkupParser parser = { start_element, end_element, text };
|
GMarkupParser parser = { start_element, end_element, text };
|
||||||
GMarkupParseContext *context;
|
|
||||||
ParseState state = { 0, };
|
ParseState state = { 0, };
|
||||||
const gchar *filename;
|
const gchar *filename;
|
||||||
|
|
||||||
context = g_markup_parse_context_new (&parser,
|
|
||||||
G_MARKUP_PREFIX_ERROR_POSITION,
|
|
||||||
&state, NULL);
|
|
||||||
|
|
||||||
state.enum_table = g_hash_table_new_full (g_str_hash, g_str_equal,
|
state.enum_table = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||||
g_free, enum_state_free);
|
g_free, enum_state_free);
|
||||||
|
|
||||||
@ -1571,9 +1566,14 @@ parse_gschema_files (gchar **files,
|
|||||||
|
|
||||||
while ((filename = *files++) != NULL)
|
while ((filename = *files++) != NULL)
|
||||||
{
|
{
|
||||||
|
GMarkupParseContext *context;
|
||||||
gchar *contents;
|
gchar *contents;
|
||||||
gsize size;
|
gsize size;
|
||||||
|
|
||||||
|
context = g_markup_parse_context_new (&parser,
|
||||||
|
G_MARKUP_PREFIX_ERROR_POSITION,
|
||||||
|
&state, NULL);
|
||||||
|
|
||||||
if (!g_file_get_contents (filename, &contents, &size, error))
|
if (!g_file_get_contents (filename, &contents, &size, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -1588,6 +1588,8 @@ parse_gschema_files (gchar **files,
|
|||||||
g_prefix_error (error, "%s: ", filename);
|
g_prefix_error (error, "%s: ", filename);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_markup_parse_context_free (context);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_hash_table_unref (state.enum_table);
|
g_hash_table_unref (state.enum_table);
|
||||||
|
Loading…
Reference in New Issue
Block a user