From 80fe32dfc60c7fbc10b92e1eb56b9f46b288f8b3 Mon Sep 17 00:00:00 2001 From: Jehan Date: Thu, 12 Jun 2025 13:16:07 +0200 Subject: [PATCH] pdb: also allow none_ok on PDB type 'guide'. This would be theoretically useful for gimp-image-find-next-guide except that this function was already using the int type, and allowing 0. I'm not changing to 'guide' type with none_ok because it would break the libgimp API (the signature would change, with the type changing from gint to guint). Since it already works like this, I just leave a TODO for further update. With this and previous commit, we now fully replaced commit 69894d8bbf attempts for allowing 0 to some types. There was in fact also some change on 'tattoo' type, but I went through all the PDB functions we had, one by one, and I don't think we currently have a single case where we need to allow 0 as a tattoo value. If this need ever arises then we can always add none_ok support easily in the future. --- pdb/app.pl | 3 ++- pdb/groups/image_guides.pdb | 1 + pdb/lib.pl | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pdb/app.pl b/pdb/app.pl index 4acca8daa9..3294a06ba3 100644 --- a/pdb/app.pl +++ b/pdb/app.pl @@ -472,11 +472,12 @@ g_param_spec_uint ("$name", CODE } elsif ($pdbtype eq 'guide') { + $min = exists $arg->{none_ok} ? 0 : 1, $pspec = < 'image', type => 'image', desc => 'The image' }, + # TODO: this should be changed to type 'guide' with none_ok => 1 when we can break API. { name => 'guide', type => '0 <= int32', default => 1, no_validate => 1, desc => 'The ID of the current guide (0 if first invocation)' } ); diff --git a/pdb/lib.pl b/pdb/lib.pl index 438539f4f4..8fe10e54f6 100644 --- a/pdb/lib.pl +++ b/pdb/lib.pl @@ -140,7 +140,7 @@ sub generate_fun { $annotate = " (array length=$retarg_len)"; } - if (exists $retarg->{none_ok} && $type ne 'sample_point') { + if (exists $retarg->{none_ok} && $type ne 'sample_point' && $type ne 'guide') { $annotate .= " (nullable)"; } @@ -294,7 +294,7 @@ sub generate_fun { $n_annotations++; } - if (exists $_->{none_ok} && $type ne 'sample_point') { + if (exists $_->{none_ok} && $type ne 'sample_point' && $type ne 'guide') { $argdesc .= " (nullable)"; $n_annotations++; }