Issue #14205: gimp-image-find-next-sample-point returns error when…

… passed "0" as argument.

Adding support of none_ok for arguments of type sample_point, allowing
to pass 0 as a special value and use it on this function.
This commit is contained in:
Jehan 2025-06-12 12:52:19 +02:00
parent 2d2f1d048d
commit bf14d3db20
4 changed files with 17 additions and 10 deletions

View file

@ -298,13 +298,13 @@ register_image_sample_points_procs (GimpPDB *pdb)
g_param_spec_uint ("sample-point",
"sample point",
"The ID of the current sample point (0 if first invocation)",
1, G_MAXUINT32, 1,
0, G_MAXUINT32, 0,
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
gimp_procedure_add_return_value (procedure,
g_param_spec_uint ("next-sample-point",
"next sample point",
"The next sample point's ID",
1, G_MAXUINT32, 1,
0, G_MAXUINT32, 0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);

View file

@ -481,11 +481,12 @@ g_param_spec_uint ("$name",
CODE
}
elsif ($pdbtype eq 'sample_point') {
$min = exists $arg->{none_ok} ? 0 : 1,
$pspec = <<CODE;
g_param_spec_uint ("$name",
"$nick",
"$blurb",
1, G_MAXUINT32, 1,
$min, G_MAXUINT32, $min,
$flags)
CODE
}

View file

@ -109,12 +109,12 @@ HELP
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image' },
{ name => 'sample_point', type => 'sample_point', no_validate => 1,
{ name => 'sample_point', type => 'sample_point', no_validate => 1, none_ok => 1,
desc => 'The ID of the current sample point (0 if first invocation)' }
);
@outargs = (
{ name => 'next_sample_point', type => 'sample_point',
{ name => 'next_sample_point', type => 'sample_point', none_ok => 1,
desc => "The next sample point's ID" }
);

View file

@ -139,7 +139,8 @@ sub generate_fun {
$retarg_len = $retarg->{array}->{name};
$annotate = " (array length=$retarg_len)";
}
if (exists $retarg->{none_ok}) {
if (exists $retarg->{none_ok} && $type ne 'sample_point') {
$annotate .= " (nullable)";
}
@ -199,6 +200,7 @@ sub generate_fun {
my $desc = exists $_->{desc} ? $_->{desc} : "";
my $var_len;
my $value;
my $n_annotations = 0;
if (exists $_->{nopdb}) {
$argc--;
@ -284,16 +286,20 @@ sub generate_fun {
if (exists $arg->{array}) {
$argdesc .= " (array length=$var_len)";
$n_annotations++;
}
if (exists $arg->{in_annotate}) {
$argdesc .= " $arg->{in_annotate}";
}
if (exists $_->{none_ok}) {
$argdesc .= " (nullable)";
$n_annotations++;
}
if (exists $arg->{array} || exists $_->{none_ok} || exists $arg->{in_annotate}) {
if (exists $_->{none_ok} && $type ne 'sample_point') {
$argdesc .= " (nullable)";
$n_annotations++;
}
if ($n_annotations > 0) {
$argdesc .= ":";
}