libgimpconfig: better error message when a GObject property tries to…

… deserialize with a wrong or unknown type.

The error message in issue #13787 was about trying to deserialize a
GimpControllerMouse object as GimpControllerInfo's controller. Yet
GimpControllerMouse was removed with commit 76ddf4421c so this was
failing.

With this change, such error would be more explicit, with an error
saying:

> Unknown object type: GimpControllerMouse

… instead of:

> unexpected character ')', expecting string constant

(which was very confusing to the actual issue)
This commit is contained in:
Jehan 2025-10-24 01:32:44 +02:00
parent 22c8860877
commit 5831b7ddcb

View file

@ -764,10 +764,21 @@ gimp_config_deserialize_object (GValue *value,
}
type = g_type_from_name (type_name);
g_free (type_name);
if (! g_type_is_a (type, prop_spec->value_type))
return G_TOKEN_STRING;
if (type == 0)
{
g_scanner_error (scanner, "Unknown object type: %s", type_name);
g_free (type_name);
return G_TOKEN_NONE;
}
else if (! g_type_is_a (type, prop_spec->value_type))
{
g_scanner_error (scanner, "Invalid object type: %s", type_name);
g_free (type_name);
return G_TOKEN_NONE;
}
g_free (type_name);
}
if (! prop_object)