From ce5efe29d645ceb812e0f05cce157aa6fdc39364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20M=C3=ADchal?= Date: Sun, 13 Jul 2025 02:18:28 +0200 Subject: [PATCH] pdb: Encode param info with unsupported type in a placeholder spec To prevent losing all information about a type (and also reporting a different API by dropping a parameter when retrieving an operation's pspecs, create a placeholder type with a known name and type and put the rest of the information into its blurb. A little hack-y but filter browser can now show information of parameters with unsupported types. --- app/pdb/drawable-filter-cmds.c | 34 +++++++++++++++++++++------------- pdb/groups/drawable_filter.pdb | 34 +++++++++++++++++++++------------- 2 files changed, 42 insertions(+), 26 deletions(-) diff --git a/app/pdb/drawable-filter-cmds.c b/app/pdb/drawable-filter-cmds.c index 236a36d5e1..c6cfe11ab6 100644 --- a/app/pdb/drawable-filter-cmds.c +++ b/app/pdb/drawable-filter-cmds.c @@ -883,22 +883,14 @@ drawable_filter_operation_get_pspecs_invoker (GimpProcedure *procedure, { GParamSpec *pspec = specs[n_parent_specs + i]; GPParamDef param_def = { 0, }; + GValue value = G_VALUE_INIT; + + g_value_init (&value, G_TYPE_PARAM); /* Make sure we do not try to send param specs over the wire * if we don't support sending their type. */ - if (_gimp_param_spec_to_gp_param_def (pspec, ¶m_def, TRUE)) - { - GValue value = G_VALUE_INIT; - - g_value_init (&value, G_TYPE_PARAM); - - g_value_set_param (&value, g_param_spec_ref (pspec)); - gimp_value_array_append (pspecs, &value); - - g_value_unset (&value); - } - else + if (! _gimp_param_spec_to_gp_param_def (pspec, ¶m_def, TRUE)) { /* This is not technically a bug if an operation has * unsupported argument types, because we cannot possibly @@ -909,11 +901,27 @@ drawable_filter_operation_get_pspecs_invoker (GimpProcedure *procedure, * want to softly notify developers, in case we can * actually do something about some types. */ - g_printerr ("%s: ignoring argument '%s' of procedure '%s'. " + g_printerr ("%s: replacing argument '%s' of procedure '%s' with a placeholder. " "Unsupported argument type '%s'.\n", G_STRFUNC, pspec->name, operation_name, g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec))); + + g_value_set_param (&value, g_param_spec_param ( + "unknown", "Unknown", + g_strdup_printf ("placeholder for unsupported type:%s:%s:%s", + pspec->name, + g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)), + g_param_spec_get_blurb (pspec)), + G_TYPE_PARAM, G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); } + else + { + g_value_set_param (&value, g_param_spec_ref (pspec)); + } + + gimp_value_array_append (pspecs, &value); + + g_value_unset (&value); } g_free (specs); diff --git a/pdb/groups/drawable_filter.pdb b/pdb/groups/drawable_filter.pdb index 2f5570b55c..e8201d07ce 100644 --- a/pdb/groups/drawable_filter.pdb +++ b/pdb/groups/drawable_filter.pdb @@ -849,22 +849,14 @@ HELP { GParamSpec *pspec = specs[n_parent_specs + i]; GPParamDef param_def = { 0, }; + GValue value = G_VALUE_INIT; + + g_value_init (&value, G_TYPE_PARAM); /* Make sure we do not try to send param specs over the wire * if we don't support sending their type. */ - if (_gimp_param_spec_to_gp_param_def (pspec, ¶m_def, TRUE)) - { - GValue value = G_VALUE_INIT; - - g_value_init (&value, G_TYPE_PARAM); - - g_value_set_param (&value, g_param_spec_ref (pspec)); - gimp_value_array_append (pspecs, &value); - - g_value_unset (&value); - } - else + if (! _gimp_param_spec_to_gp_param_def (pspec, ¶m_def, TRUE)) { /* This is not technically a bug if an operation has * unsupported argument types, because we cannot possibly @@ -875,11 +867,27 @@ HELP * want to softly notify developers, in case we can * actually do something about some types. */ - g_printerr ("%s: ignoring argument '%s' of procedure '%s'. " + g_printerr ("%s: replacing argument '%s' of procedure '%s' with a placeholder. " "Unsupported argument type '%s'.\n", G_STRFUNC, pspec->name, operation_name, g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec))); + + g_value_set_param (&value, g_param_spec_param ( + "unknown", "Unknown", + g_strdup_printf ("placeholder for unsupported type:%s:%s:%s", + pspec->name, + g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)), + g_param_spec_get_blurb (pspec)), + G_TYPE_PARAM, G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); } + else + { + g_value_set_param (&value, g_param_spec_ref (pspec)); + } + + gimp_value_array_append (pspecs, &value); + + g_value_unset (&value); } g_free (specs);