[gimp] libgimp: make sure GimpProcedures always get all their arguments
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimp: make sure GimpProcedures always get all their arguments
- Date: Sat, 3 Aug 2019 15:10:59 +0000 (UTC)
commit 5b8deb68b45fb2cb27fa7ed084c8a222604ad2c5
Author: Michael Natterer <mitch gimp org>
Date: Sat Aug 3 16:56:31 2019 +0200
libgimp: make sure GimpProcedures always get all their arguments
gimp_procedure_run(): fill the value array with default values so a
procedure's run callback always gets a complete value array. No more
number-of-arguments checking in any new-style plug-in.
libgimp/gimpprocedure.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
---
diff --git a/libgimp/gimpprocedure.c b/libgimp/gimpprocedure.c
index c678d319d5..9cb8b03bbd 100644
--- a/libgimp/gimpprocedure.c
+++ b/libgimp/gimpprocedure.c
@@ -922,6 +922,7 @@ gimp_procedure_run (GimpProcedure *procedure,
{
GimpValueArray *return_vals;
GError *error = NULL;
+ gint i;
g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
g_return_val_if_fail (args != NULL, NULL);
@@ -939,6 +940,18 @@ gimp_procedure_run (GimpProcedure *procedure,
return return_vals;
}
+ /* add missing args with default values */
+ for (i = gimp_value_array_length (args); i < procedure->priv->n_args; i++)
+ {
+ GParamSpec *pspec = procedure->priv->args[i];
+ GValue value = G_VALUE_INIT;
+
+ g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+ g_param_value_set_default (pspec, &value);
+ gimp_value_array_append (args, &value);
+ g_value_unset (&value);
+ }
+
/* call the procedure */
return_vals = procedure->priv->run_func (procedure, args,
procedure->priv->run_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]