app, libgimp, pdb: fix setting NULL to gimp_image_set_color_profile() and…

… gimp_image_set_simulation_profile().

It looks like NULL through the PDB for 'bytes' argument gets passed as a
GBytes of size 0 (which might be something I did, and to be fair, that's
fine; I just forgot having done this).
As a consequence, testing for NULL was wrong, and these 2 functions were
always failing with NULL. Now they behave appropriately.

I also improve the docs for both functions.
This commit is contained in:
Jehan 2026-03-11 21:39:50 +01:00
parent dbbab9ef23
commit 483a2e0eed
4 changed files with 13 additions and 8 deletions

View file

@ -143,7 +143,7 @@ image_set_color_profile_invoker (GimpProcedure *procedure,
if (success)
{
if (color_profile)
if (color_profile && g_bytes_get_size (color_profile) > 0)
{
GimpColorProfile *profile;
@ -272,7 +272,7 @@ image_set_simulation_profile_invoker (GimpProcedure *procedure,
if (success)
{
if (color_profile)
if (color_profile && g_bytes_get_size (color_profile) > 0)
{
GimpColorProfile *profile;

View file

@ -67,6 +67,9 @@ gimp_image_get_color_profile (GimpImage *image)
*
* This procedure sets the image's color profile.
*
* If %NULL is passed as @profile, then the built-in profile for
* @image's color model is set.
*
* Returns: %TRUE on success.
*
* Since: 2.10
@ -140,6 +143,8 @@ gimp_image_get_simulation_profile (GimpImage *image)
*
* This procedure sets the image's simulation color profile.
*
* If %NULL is passed as @profile, then the simulation profile is unset.
*
* Returns: %TRUE on success.
*
* Since: 3.0

View file

@ -116,7 +116,7 @@ _gimp_image_get_effective_color_profile (GimpImage *image)
/**
* _gimp_image_set_color_profile:
* @image: The image.
* @color_profile: The new serialized color profile.
* @color_profile: (nullable): The new serialized color profile.
*
* Sets the image's color profile
*
@ -238,7 +238,7 @@ _gimp_image_get_simulation_profile (GimpImage *image)
/**
* _gimp_image_set_simulation_profile:
* @image: The image.
* @color_profile: The new serialized simulation color profile.
* @color_profile: (nullable): The new serialized simulation color profile.
*
* Sets the image's simulation color profile
*

View file

@ -122,14 +122,14 @@ HELP
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image' },
{ name => 'color_profile', type => 'bytes',
{ name => 'color_profile', type => 'bytes', none_ok => 1,
desc => 'The new serialized color profile' }
);
%invoke = (
code => <<'CODE'
{
if (color_profile)
if (color_profile && g_bytes_get_size (color_profile) > 0)
{
GimpColorProfile *profile;
@ -263,14 +263,14 @@ HELP
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image' },
{ name => 'color_profile', type => 'bytes',
{ name => 'color_profile', type => 'bytes', none_ok => 1,
desc => 'The new serialized simulation color profile'}
);
%invoke = (
code => <<'CODE'
{
if (color_profile)
if (color_profile && g_bytes_get_size (color_profile) > 0)
{
GimpColorProfile *profile;