libgimp, pdb: improve free function information on array types.

Core object arrays must also be freed with g_free() (since elements are
not ref-ed).

Also color arrays must be freed with gimp_color_array_free().
This commit is contained in:
Jehan 2024-10-23 22:50:45 +02:00
parent 4137dce97b
commit 87d3d921da
7 changed files with 18 additions and 3 deletions

View File

@ -188,6 +188,7 @@ gimp_edit_copy_visible (GimpImage *image)
*
* Returns: (element-type GimpDrawable) (array zero-terminated=1) (transfer container):
* The list of pasted layers.
* The returned value must be freed with g_free().
**/
GimpDrawable **
gimp_edit_paste (GimpDrawable *drawable,

View File

@ -135,6 +135,7 @@ gimp_file_load_layer (GimpRunMode run_mode,
*
* Returns: (element-type GimpLayer) (array zero-terminated=1) (transfer container):
* The list of loaded layers.
* The returned value must be freed with g_free().
*
* Since: 2.4
**/

View File

@ -125,6 +125,7 @@ gimp_font_get_by_name (const gchar *name)
*
* Returns: (element-type GimpFont) (array zero-terminated=1) (transfer container):
* The fonts with the given name.
* The returned value must be freed with g_free().
*
* Since: 3.0
**/

View File

@ -83,6 +83,7 @@ gimp_image_id_is_valid (gint image_id)
*
* Returns: (element-type GimpImage) (array zero-terminated=1) (transfer container):
* The list of images currently open.
* The returned value must be freed with g_free().
**/
GimpImage **
gimp_get_images (void)
@ -472,6 +473,7 @@ gimp_image_get_height (GimpImage *image)
*
* Returns: (element-type GimpLayer) (array zero-terminated=1) (transfer container):
* The list of layers contained in the image.
* The returned value must be freed with g_free().
**/
GimpLayer **
gimp_image_get_layers (GimpImage *image)
@ -511,6 +513,7 @@ gimp_image_get_layers (GimpImage *image)
*
* Returns: (element-type GimpChannel) (array zero-terminated=1) (transfer container):
* The list of channels contained in the image.
* The returned value must be freed with g_free().
**/
GimpChannel **
gimp_image_get_channels (GimpImage *image)
@ -547,6 +550,7 @@ gimp_image_get_channels (GimpImage *image)
*
* Returns: (element-type GimpPath) (array zero-terminated=1) (transfer container):
* The list of paths contained in the image.
* The returned value must be freed with g_free().
*
* Since: 2.4
**/
@ -2164,6 +2168,7 @@ _gimp_image_thumbnail (GimpImage *image,
*
* Returns: (element-type GimpLayer) (array zero-terminated=1) (transfer container):
* The list of selected layers in the image.
* The returned value must be freed with g_free().
*
* Since: 3.0.0
**/
@ -2243,6 +2248,7 @@ gimp_image_set_selected_layers (GimpImage *image,
*
* Returns: (element-type GimpChannel) (array zero-terminated=1) (transfer container):
* The list of selected channels in the image.
* The returned value must be freed with g_free().
*
* Since: 3.0.0
**/
@ -2322,6 +2328,7 @@ gimp_image_set_selected_channels (GimpImage *image,
*
* Returns: (element-type GimpPath) (array zero-terminated=1) (transfer container):
* The list of selected paths in the image.
* The returned value must be freed with g_free().
*
* Since: 3.0.0
**/
@ -2403,6 +2410,7 @@ gimp_image_set_selected_paths (GimpImage *image,
*
* Returns: (element-type GimpDrawable) (array zero-terminated=1) (transfer container):
* The list of selected drawables in the image.
* The returned value must be freed with g_free().
*
* Since: 3.0.0
**/

View File

@ -568,6 +568,7 @@ gimp_item_get_parent (GimpItem *item)
*
* Returns: (element-type GimpItem) (array zero-terminated=1) (transfer container):
* The item's list of children.
* The returned value must be freed with g_free().
*
* Since: 2.8
**/

View File

@ -159,6 +159,7 @@ gimp_palette_get_color_count (GimpPalette *palette)
*
* Returns: (array zero-terminated=1) (transfer full):
* The colors in the palette.
* The returned value must be freed with gimp_color_array_free().
*
* Since: 2.6
**/

View File

@ -162,8 +162,10 @@ sub generate_fun {
unless ($retdesc =~ /[\.\!\?]$/) { $retdesc .= '.' }
if ($retarg->{type} eq 'string') {
$retdesc .= "\n * The returned value must be freed with g_free().";
my $array_test = $retarg->{type};
$array_test =~ s/array$//g;
if ($retarg->{type} eq 'colorarray') {
$retdesc .= "\n * The returned value must be freed with gimp_color_array_free().";
}
elsif ($retarg->{type} eq 'strv') {
$retdesc .= "\n * The returned value must be freed with g_strfreev().";
@ -171,7 +173,7 @@ sub generate_fun {
elsif ($retarg->{type} eq 'param') {
$retdesc .= "\n * The returned value must be freed with g_param_spec_unref().";
}
elsif (exists $argtype->{array}) {
elsif ($retarg->{type} eq 'string' || $retarg->{type} ne $array_test) {
$retdesc .= "\n * The returned value must be freed with g_free().";
}
}