[gimp] Issue #6033: fix calling gimp_pdb_run_procedure_argv() with no…
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Issue #6033: fix calling gimp_pdb_run_procedure_argv() with no…
- Date: Thu, 8 Apr 2021 21:14:05 +0000 (UTC)
commit cbce7b3a982fa5fc1b2b5edc1a3ff358f030baad
Author: Lloyd Konneker <konnekerl gmail com>
Date: Thu Apr 8 21:14:02 2021 +0000
Issue #6033: fix calling gimp_pdb_run_procedure_argv() with no…
… arguments and allow creating empty GimpValueArray.
libgimp/gimppdb.c | 12 +++++++-----
libgimpbase/gimpvaluearray.c | 8 +++++---
2 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/libgimp/gimppdb.c b/libgimp/gimppdb.c
index 1b961b6d44..a8c64251c7 100644
--- a/libgimp/gimppdb.c
+++ b/libgimp/gimppdb.c
@@ -281,10 +281,10 @@ gimp_pdb_run_procedure_valist (GimpPDB *pdb,
/**
* gimp_pdb_run_procedure_argv: (rename-to gimp_pdb_run_procedure)
- * @pdb: the #GimpPDB object.
- * @procedure_name: the procedure registered name.
- * @arguments: (array length=n_arguments): the call arguments.
- * @n_arguments: the number of arguments.
+ * @pdb: the #GimpPDB object.
+ * @procedure_name: the registered name to call.
+ * @arguments: (array length=n_arguments) (nullable): the call arguments or %NULL.
+ * @n_arguments: the number of arguments.
*
* Runs the procedure named @procedure_name with @arguments.
*
@@ -303,7 +303,9 @@ gimp_pdb_run_procedure_argv (GimpPDB *pdb,
g_return_val_if_fail (GIMP_IS_PDB (pdb), NULL);
g_return_val_if_fail (gimp_is_canonical_identifier (procedure_name), NULL);
- g_return_val_if_fail (arguments != NULL, NULL);
+ /* Not require arguments != NULL.
+ * gimp_value_array_new_from_values(NULL, 0) will return empty GValueArray.
+ */
args = gimp_value_array_new_from_values (arguments, n_arguments);
return_values = gimp_pdb_run_procedure_array (pdb, procedure_name, args);
diff --git a/libgimpbase/gimpvaluearray.c b/libgimpbase/gimpvaluearray.c
index 6923e47647..d0bbc867c6 100644
--- a/libgimpbase/gimpvaluearray.c
+++ b/libgimpbase/gimpvaluearray.c
@@ -256,7 +256,7 @@ gimp_value_array_new_from_types_valist (gchar **error_msg,
* @n_values: the number of value elements
*
* Allocate and initialize a new #GimpValueArray, and fill it with
- * the given #GValues.
+ * the given #GValues. When no #GValues are given, returns empty #GimpValueArray.
*
* Returns: a newly allocated #GimpValueArray.
*
@@ -269,8 +269,10 @@ gimp_value_array_new_from_values (const GValue *values,
GimpValueArray *value_array;
gint i;
- g_return_val_if_fail (values != NULL, NULL);
- g_return_val_if_fail (n_values > 0, NULL);
+ /* n_values is zero if and only if values is NULL. */
+ g_return_val_if_fail ((n_values == 0 && values == NULL) ||
+ (n_values > 0 && values != NULL),
+ NULL);
value_array = gimp_value_array_new (n_values);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]