diff --git a/plug-ins/script-fu/libscriptfu/script-fu-run-func.c b/plug-ins/script-fu/libscriptfu/script-fu-run-func.c index 4a2eea3361..8da79c2ce9 100644 --- a/plug-ins/script-fu/libscriptfu/script-fu-run-func.c +++ b/plug-ins/script-fu/libscriptfu/script-fu-run-func.c @@ -175,11 +175,8 @@ script_fu_run_procedure (GimpProcedure *procedure, } case GIMP_RUN_NONINTERACTIVE: - /* Verify actual args count equals declared arg count. - * Scripts declare args except run_mode (SF hides it.) - * pspecs have run_mode and one extra internal pspec, thus +2. - */ - if (n_pspecs != script->n_args + n_aux_args + 2) + /* Verify actual args count equals declared arg count. */ + if (n_pspecs != script->n_args + n_aux_args + SF_ARG_TO_CONFIG_OFFSET) status = GIMP_PDB_CALLING_ERROR; if (status == GIMP_PDB_SUCCESS) diff --git a/plug-ins/script-fu/libscriptfu/script-fu-script.c b/plug-ins/script-fu/libscriptfu/script-fu-script.c index 10d67b06cb..62a1e4aa3c 100644 --- a/plug-ins/script-fu/libscriptfu/script-fu-script.c +++ b/plug-ins/script-fu/libscriptfu/script-fu-script.c @@ -357,7 +357,7 @@ script_fu_script_get_command_from_params (SFScript *script, for (i = 0; i < script->n_args; i++) { GValue value = G_VALUE_INIT; - GParamSpec *pspec = pspecs[i + 1]; + GParamSpec *pspec = pspecs[i + SF_ARG_TO_CONFIG_OFFSET]; g_value_init (&value, pspec->value_type); g_object_get_property (G_OBJECT (config), pspec->name, &value); @@ -495,10 +495,10 @@ script_fu_script_param_init (SFScript *script, if (script->n_args > n && arg->type == type && /* The first pspec is "procedure", the second is "run-mode". */ - n_pspecs > n + 2) + n_pspecs > n + SF_ARG_TO_CONFIG_OFFSET) { GValue value = G_VALUE_INIT; - GParamSpec *pspec = pspecs[n + 2]; + GParamSpec *pspec = pspecs[n + SF_ARG_TO_CONFIG_OFFSET]; g_value_init (&value, pspec->value_type); g_object_get_property (G_OBJECT (config), pspec->name, &value); diff --git a/plug-ins/script-fu/libscriptfu/script-fu-types.h b/plug-ins/script-fu/libscriptfu/script-fu-types.h index 91646cf359..7603738c70 100644 --- a/plug-ins/script-fu/libscriptfu/script-fu-types.h +++ b/plug-ins/script-fu/libscriptfu/script-fu-types.h @@ -94,6 +94,14 @@ typedef struct GType proc_class; /* GimpProcedure or GimpImageProcedure. */ } SFScript; +/* ScriptFu keeps array of SFArg, it's private arg specs. + * Scripts declare args except run_mode (SF hides it.) + * A GimpConfig has two extra leading properties, for procedure and run_mode. + * A set of GParamSpecs is derived from a config and also has two extra. + * This defines the difference in length between SF's arg spec array and a config. + */ +#define SF_ARG_TO_CONFIG_OFFSET 2 + typedef struct { SFScript *script; /* script which defined this menu path and label */