[gimp] libgimp: transfer ownership of @error parameter to...



commit 67a0451ac5359a48d745decbb40ae65e0d2e3ed9
Author: Jehan <jehan girinstud io>
Date:   Thu Aug 1 16:00:36 2019 +0200

    libgimp: transfer ownership of @error parameter to...
    
    ... gimp_procedure_new_return_values().
    When we see how this has been used in help or goat-exercise plug-ins so
    far, we clearly see that we expect this function to be used as last call
    in a run callback. Well we could save the result, free the error, then
    return the result, but it's cumbersome.
    So instead let's officially expect gimp_procedure_new_return_values() to
    take ownership of the GError (i.e. it will free it in the end).
    For this reason, remove the `const`.

 libgimp/gimpprocedure.c | 8 +++++---
 libgimp/gimpprocedure.h | 2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/libgimp/gimpprocedure.c b/libgimp/gimpprocedure.c
index d3c27f5c21..1a76f241fc 100644
--- a/libgimp/gimpprocedure.c
+++ b/libgimp/gimpprocedure.c
@@ -476,8 +476,9 @@ gimp_procedure_new_arguments (GimpProcedure *procedure)
  * gimp_procedure_new_return_values:
  * @procedure: the #GimpProcedure.
  * @status:    the success status of the procedure run.
- * @error:     (nullable): an optional #GError. This parameter should be
- *             set if @status is either #GIMP_PDB_EXECUTION_ERROR or
+ * @error:     (in) (nullable) (transfer full):
+ *             an optional #GError. This parameter should be set if
+ *             @status is either #GIMP_PDB_EXECUTION_ERROR or
  *             #GIMP_PDB_CALLING_ERROR.
  *
  * Format the expected return values from procedures, using the return
@@ -489,7 +490,7 @@ gimp_procedure_new_arguments (GimpProcedure *procedure)
 GimpValueArray *
 gimp_procedure_new_return_values (GimpProcedure     *procedure,
                                   GimpPDBStatusType  status,
-                                  const GError      *error)
+                                  GError            *error)
 {
   GimpValueArray *args;
   GValue          value = G_VALUE_INIT;
@@ -539,6 +540,7 @@ gimp_procedure_new_return_values (GimpProcedure     *procedure,
     default:
       g_return_val_if_reached (NULL);
     }
+  g_clear_error (&error);
 
   return args;
 }
diff --git a/libgimp/gimpprocedure.h b/libgimp/gimpprocedure.h
index 0fe740dc6f..0b123b9f58 100644
--- a/libgimp/gimpprocedure.h
+++ b/libgimp/gimpprocedure.h
@@ -113,7 +113,7 @@ GParamSpec    ** gimp_procedure_get_return_values  (GimpProcedure     *procedure
 GimpValueArray * gimp_procedure_new_arguments      (GimpProcedure     *procedure);
 GimpValueArray * gimp_procedure_new_return_values  (GimpProcedure     *procedure,
                                                     GimpPDBStatusType  status,
-                                                    const GError      *error);
+                                                    GError            *error);
 
 GimpValueArray * gimp_procedure_run                (GimpProcedure     *procedure,
                                                     GimpValueArray    *args);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]