From 483a2e0eed02f3e76fe608c73e05a1f53f250767 Mon Sep 17 00:00:00 2001 From: Jehan Date: Wed, 11 Mar 2026 21:39:50 +0100 Subject: [PATCH] =?UTF-8?q?app,=20libgimp,=20pdb:=20fix=20setting=20NULL?= =?UTF-8?q?=20to=20gimp=5Fimage=5Fset=5Fcolor=5Fprofile()=20and=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … 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. --- app/pdb/image-color-profile-cmds.c | 4 ++-- libgimp/gimpimagecolorprofile.c | 5 +++++ libgimp/gimpimagecolorprofile_pdb.c | 4 ++-- pdb/groups/image_color_profile.pdb | 8 ++++---- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/pdb/image-color-profile-cmds.c b/app/pdb/image-color-profile-cmds.c index 806bbd2e95..855f081dbc 100644 --- a/app/pdb/image-color-profile-cmds.c +++ b/app/pdb/image-color-profile-cmds.c @@ -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; diff --git a/libgimp/gimpimagecolorprofile.c b/libgimp/gimpimagecolorprofile.c index 71c99b56f0..ff7894dfdc 100644 --- a/libgimp/gimpimagecolorprofile.c +++ b/libgimp/gimpimagecolorprofile.c @@ -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 diff --git a/libgimp/gimpimagecolorprofile_pdb.c b/libgimp/gimpimagecolorprofile_pdb.c index 0ce5d6ee22..635ec010ba 100644 --- a/libgimp/gimpimagecolorprofile_pdb.c +++ b/libgimp/gimpimagecolorprofile_pdb.c @@ -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 * diff --git a/pdb/groups/image_color_profile.pdb b/pdb/groups/image_color_profile.pdb index 8f2f81bae6..bbbbf420d2 100644 --- a/pdb/groups/image_color_profile.pdb +++ b/pdb/groups/image_color_profile.pdb @@ -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;