(in) (nullable) GError * parameter not accepted as None
So we've got an API which takes a GError *
as (in) argument, and we want this to be optional (actually most of the time, you should not run it with a NULL). So we added (nullable)
(cf. also source).
/**
* gimp_procedure_new_return_values:
* @procedure: the #GimpProcedure.
* @status: the success status of the procedure run.
* @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
* values set with gimp_procedure_add_return_value().
*
* Returns: the expected #GimpValueArray as could be returned by a
* #GimpRunFunc.
*/
Yet calling it from Python generates an error:
Traceback (most recent call last):
File "/home/jehan/.local/share/crossroad/roads/native/gimp/lib/gimp/2.99/plug-ins/palette-to-gradient/palette-to-gradient.py", line 115, in run_palette_to_gradient
return procedure.new_return_values(Gimp.PDBStatusType.SUCCESS, None)
TypeError: Must be GLib.Error, not NoneType
Apparently there might be special casing in pygobject forbidding a GError* to end up NULL?
Cf. also the Gimp-3.0.gir
file which looks good:
<method name="new_return_values"
c:identifier="gimp_procedure_new_return_values">
<doc xml:space="preserve"
filename="src/gimp/libgimp/gimpprocedure.c"
line="475">Format the expected return values from procedures, using the return
values set with gimp_procedure_add_return_value().</doc>
<source-position filename="src/gimp/libgimp/gimpprocedure.h"
line="114"/>
<return-value transfer-ownership="full">
<doc xml:space="preserve"
filename="src/gimp/libgimp/gimpprocedure.c"
line="487">the expected #GimpValueArray as could be returned by a
#GimpRunFunc.</doc>
<type name="ValueArray" c:type="GimpValueArray*"/>
</return-value>
<parameters>
<instance-parameter name="procedure" transfer-ownership="none">
<doc xml:space="preserve"
filename="src/gimp/libgimp/gimpprocedure.c"
line="477">the #GimpProcedure.</doc>
<type name="Procedure" c:type="GimpProcedure*"/>
</instance-parameter>
<parameter name="status" transfer-ownership="none">
<doc xml:space="preserve"
filename="src/gimp/libgimp/gimpprocedure.c"
line="478">the success status of the procedure run.</doc>
<type name="PDBStatusType" c:type="GimpPDBStatusType"/>
</parameter>
<parameter name="error"
transfer-ownership="full"
nullable="1"
allow-none="1">
<doc xml:space="preserve"
filename="src/gimp/libgimp/gimpprocedure.c"
line="479">
an optional #GError. This parameter should be set if
@status is either #GIMP_PDB_EXECUTION_ERROR or
#GIMP_PDB_CALLING_ERROR.</doc>
<type name="GLib.Error" c:type="GError*"/>
</parameter>
</parameters>
</method>
Edited by Jehan