libgimpconfig: this is the appropriate fix for the previous assert.

Since the parsing failure I was experiencing was normal (not a bug), and
since I was not seeing error being passed down to deserialize(), I
assume this assert was always wrong. I hadn't realize that the GError
object was in fact populated by deserialized through g_scanner_error()
calls which were setting the GError passed at creation of the scanner
through a handler.

So there was indeed a bug in one of the functions called by our
deserialize() implementation. There was one failure case where the error
was just reported with g_warning() instead of g_scanner_error().

Now that it's fixed, I brought back the asserts (previous commits)
because the error object is actually always well populated.
This commit is contained in:
Jehan 2022-02-10 22:09:43 +01:00
parent f4c7ea7e02
commit e6350f9459
2 changed files with 8 additions and 2 deletions

View file

@ -1009,8 +1009,9 @@ gimp_config_deserialize_any (GValue *value,
if (!g_value_type_transformable (G_TYPE_STRING, prop_spec->value_type))
{
g_warning ("%s: %s can not be transformed from a string",
G_STRFUNC, g_type_name (prop_spec->value_type));
g_scanner_error (scanner,
"%s can not be transformed from a string",
g_type_name (prop_spec->value_type));
return G_TOKEN_NONE;
}

View file

@ -495,6 +495,11 @@ gimp_config_deserialize_file (GimpConfig *config,
gimp_scanner_unref (scanner);
if (! success)
/* If we get this assert, it means we have a bug in one of the
* deserialize() implementations. Any failure case should report the
* error condition with g_scanner_error() which will populate the
* error object passed in gimp_scanner_new*().
*/
g_assert (error == NULL || *error != NULL);
return success;