app: relax GIMP_TYPE_INT32 checks in gimp_pdb_execute_procedure_by_name()

allow to pass booleans and enums to GIMP_TYPE_INT32 arguments. We
didn't have them in the old plug-in API, and being less strict allows
for booleans and enums being passed to old procedures transparently.
This commit is contained in:
Michael Natterer 2019-08-04 13:50:15 +02:00
parent c822350fb3
commit 4962428440
1 changed files with 26 additions and 2 deletions

View File

@ -390,6 +390,7 @@ gimp_pdb_execute_procedure_by_name (GimpPDB *pdb,
{
GValue *value;
GType arg_type;
GType value_type;
gchar *error_msg = NULL;
arg_type = va_arg (va_args, GType);
@ -399,10 +400,33 @@ gimp_pdb_execute_procedure_by_name (GimpPDB *pdb,
value = gimp_value_array_index (args, i);
if (arg_type != G_VALUE_TYPE (value))
value_type = G_VALUE_TYPE (value);
/* GIMP_TYPE_INT32 is widely abused for enums and booleans in
* old plug-ins, silently copy stuff into integers when enums
* and booleans are passed
*/
if (arg_type != value_type
&&
(value_type == G_TYPE_INT ||
value_type == GIMP_TYPE_INT32)
&&
(arg_type == G_TYPE_INT ||
arg_type == GIMP_TYPE_INT32 ||
arg_type == G_TYPE_BOOLEAN ||
g_type_is_a (arg_type, G_TYPE_ENUM)))
{
arg_type = value_type;
}
if (arg_type != value_type)
{
GError *pdb_error;
const gchar *expected = g_type_name (G_VALUE_TYPE (value));
const gchar *expected = g_type_name (value_type);
const gchar *got = g_type_name (arg_type);
gimp_value_array_unref (args);