From f17a42be7586877459fcf02aedb6bf3b00a3341e Mon Sep 17 00:00:00 2001 From: Jehan Date: Mon, 20 Jan 2025 15:25:32 +0100 Subject: [PATCH] plug-ins: add type check for the argument names in filter configuration too. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After the few specific args (drawable/filter ID, opacity, blend mode, op name…), the op argument names can be passed either as string or with the new argument name syntax. The error message though focus on argument name type. Also fix the argument count for the various possible cases (when configuring with (gimp-drawable-filter-configure) or (gimp-drawable-merge|append-new-filter), the start arg count is different). --- plug-ins/script-fu/libscriptfu/scheme-wrapper.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/plug-ins/script-fu/libscriptfu/scheme-wrapper.c b/plug-ins/script-fu/libscriptfu/scheme-wrapper.c index b624769954..5513df1f92 100644 --- a/plug-ins/script-fu/libscriptfu/scheme-wrapper.c +++ b/plug-ins/script-fu/libscriptfu/scheme-wrapper.c @@ -1845,13 +1845,13 @@ static pointer script_fu_marshal_drawable_filter_configure (scheme *sc, pointer a, const gchar *proc_name, + gint arg_index, GimpDrawableFilter *filter) { pointer return_val = sc->NIL; GimpLayerMode mode = GIMP_LAYER_MODE_REPLACE; gdouble opacity = 1.0; GimpDrawableFilterConfig *config; - gint arg_index; gchar error_str[1024]; if (sc->vptr->list_length (sc, a) > 0) @@ -1868,14 +1868,21 @@ script_fu_marshal_drawable_filter_configure (scheme *sc, gimp_drawable_filter_set_opacity (filter, opacity); gimp_drawable_filter_set_blend_mode (filter, mode); - config = gimp_drawable_filter_get_config (filter); - arg_index = 3; + config = gimp_drawable_filter_get_config (filter); while (sc->vptr->list_length (sc, a) > 1) { gchar *argname; GParamSpec *arg_spec; GValue value = G_VALUE_INIT; + if (! sc->vptr->is_arg_name (sc->vptr->pair_car (a)) && + ! sc->vptr->is_string (sc->vptr->pair_car (a))) + { + g_snprintf (error_str, sizeof (error_str), + "Expected argument name for argument %d", arg_index); + return script_error (sc, error_str, 0); + } + argname = g_strdup (sc->vptr->string_value (sc->vptr->pair_car (a))); arg_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (config), argname); if (arg_spec == NULL) @@ -1985,7 +1992,7 @@ script_fu_marshal_drawable_create_filter (scheme *sc, } g_free (operation_name); - return script_fu_marshal_drawable_filter_configure (sc, a, proc_name, *filter); + return script_fu_marshal_drawable_filter_configure (sc, a, proc_name, 5, *filter); } static pointer @@ -2037,7 +2044,7 @@ script_fu_marshal_drawable_filter_configure_call (scheme *sc, a = sc->vptr->pair_cdr (a); } - return script_fu_marshal_drawable_filter_configure (sc, a, proc_name, filter); + return script_fu_marshal_drawable_filter_configure (sc, a, proc_name, 3, filter); } static pointer