From 69894d8bbff24c85f8d98c65e0a2951ae7f8d1e2 Mon Sep 17 00:00:00 2001 From: lloyd konneker Date: Sat, 7 Jun 2025 09:40:55 -0400 Subject: [PATCH] PDB: fix #14205 image-find-next-sample-point error Three types declared in pdbgen perl code, for sample-point, guides, and tatto objects, declare too restrictive a range of permissible values. They should allow the value 0, which the API uses as a sentinel value, to represent "invalid object ID". The types are for object ID's, which are unsigned. GObject checks the declared range when you chunk into a GValueArray, to call the PDB. Declaring the attribute in the perl .pdb "no-validate" is not sufficient since GObject doesn't understand GIMP_PARAM_NO_VALIDATE, that flag is distinct from G_PARAM_NO_VALIDATE. Only affects the ScriptFu binding to PDB. The GI binding to libgimp is not affected. The declared range is no more restrictive than the underlying type "unsigned int 32." So of no real consequence. The API could be changed to return a list which the caller would iterate on. --- app/pdb/image-cmds.c | 10 +++++----- app/pdb/image-guides-cmds.c | 12 ++++++------ app/pdb/image-sample-points-cmds.c | 10 +++++----- app/pdb/item-cmds.c | 4 ++-- pdb/app.pl | 6 +++--- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/app/pdb/image-cmds.c b/app/pdb/image-cmds.c index 449c9fd53a..f5cb86985f 100644 --- a/app/pdb/image-cmds.c +++ b/app/pdb/image-cmds.c @@ -5439,7 +5439,7 @@ register_image_procs (GimpPDB *pdb) g_param_spec_uint ("tattoo-state", "tattoo state", "The tattoo state", - 1, G_MAXUINT32, 1, + 0, G_MAXUINT32, 1, GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); @@ -5468,7 +5468,7 @@ register_image_procs (GimpPDB *pdb) g_param_spec_uint ("tattoo-state", "tattoo state", "The new image tattoo state", - 1, G_MAXUINT32, 1, + 0, G_MAXUINT32, 1, GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); @@ -5497,7 +5497,7 @@ register_image_procs (GimpPDB *pdb) g_param_spec_uint ("tattoo", "tattoo", "The tattoo of the layer to find", - 1, G_MAXUINT32, 1, + 0, G_MAXUINT32, 1, GIMP_PARAM_READWRITE)); gimp_procedure_add_return_value (procedure, gimp_param_spec_layer ("layer", @@ -5532,7 +5532,7 @@ register_image_procs (GimpPDB *pdb) g_param_spec_uint ("tattoo", "tattoo", "The tattoo of the channel to find", - 1, G_MAXUINT32, 1, + 0, G_MAXUINT32, 1, GIMP_PARAM_READWRITE)); gimp_procedure_add_return_value (procedure, gimp_param_spec_channel ("channel", @@ -5567,7 +5567,7 @@ register_image_procs (GimpPDB *pdb) g_param_spec_uint ("tattoo", "tattoo", "The tattoo of the path to find", - 1, G_MAXUINT32, 1, + 0, G_MAXUINT32, 1, GIMP_PARAM_READWRITE)); gimp_procedure_add_return_value (procedure, gimp_param_spec_path ("path", diff --git a/app/pdb/image-guides-cmds.c b/app/pdb/image-guides-cmds.c index 29835fb21e..964980e186 100644 --- a/app/pdb/image-guides-cmds.c +++ b/app/pdb/image-guides-cmds.c @@ -296,7 +296,7 @@ register_image_guides_procs (GimpPDB *pdb) g_param_spec_uint ("guide", "guide", "The new guide", - 1, G_MAXUINT32, 1, + 0, G_MAXUINT32, 1, GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); @@ -331,7 +331,7 @@ register_image_guides_procs (GimpPDB *pdb) g_param_spec_uint ("guide", "guide", "The new guide", - 1, G_MAXUINT32, 1, + 0, G_MAXUINT32, 1, GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); @@ -360,7 +360,7 @@ register_image_guides_procs (GimpPDB *pdb) g_param_spec_uint ("guide", "guide", "The ID of the guide to be removed", - 1, G_MAXUINT32, 1, + 0, G_MAXUINT32, 1, GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); @@ -395,7 +395,7 @@ register_image_guides_procs (GimpPDB *pdb) g_param_spec_uint ("next-guide", "next guide", "The next guide's ID", - 1, G_MAXUINT32, 1, + 0, G_MAXUINT32, 1, GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); @@ -424,7 +424,7 @@ register_image_guides_procs (GimpPDB *pdb) g_param_spec_uint ("guide", "guide", "The guide", - 1, G_MAXUINT32, 1, + 0, G_MAXUINT32, 1, GIMP_PARAM_READWRITE)); gimp_procedure_add_return_value (procedure, gimp_param_spec_enum ("orientation", @@ -462,7 +462,7 @@ register_image_guides_procs (GimpPDB *pdb) g_param_spec_uint ("guide", "guide", "The guide", - 1, G_MAXUINT32, 1, + 0, G_MAXUINT32, 1, GIMP_PARAM_READWRITE)); gimp_procedure_add_return_value (procedure, g_param_spec_int ("position", diff --git a/app/pdb/image-sample-points-cmds.c b/app/pdb/image-sample-points-cmds.c index 1a17fafbca..4f0fe8d6c3 100644 --- a/app/pdb/image-sample-points-cmds.c +++ b/app/pdb/image-sample-points-cmds.c @@ -240,7 +240,7 @@ register_image_sample_points_procs (GimpPDB *pdb) g_param_spec_uint ("sample-point", "sample point", "The new sample point", - 1, G_MAXUINT32, 1, + 0, G_MAXUINT32, 1, GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); @@ -269,7 +269,7 @@ register_image_sample_points_procs (GimpPDB *pdb) g_param_spec_uint ("sample-point", "sample point", "The ID of the sample point to be removed", - 1, G_MAXUINT32, 1, + 0, G_MAXUINT32, 1, GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); @@ -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, 1, 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, 1, GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); @@ -333,7 +333,7 @@ register_image_sample_points_procs (GimpPDB *pdb) g_param_spec_uint ("sample-point", "sample point", "The guide", - 1, G_MAXUINT32, 1, + 0, G_MAXUINT32, 1, GIMP_PARAM_READWRITE)); gimp_procedure_add_return_value (procedure, g_param_spec_int ("position-x", diff --git a/app/pdb/item-cmds.c b/app/pdb/item-cmds.c index 0e547397b5..163a8dfa4f 100644 --- a/app/pdb/item-cmds.c +++ b/app/pdb/item-cmds.c @@ -1919,7 +1919,7 @@ register_item_procs (GimpPDB *pdb) g_param_spec_uint ("tattoo", "tattoo", "The item tattoo", - 1, G_MAXUINT32, 1, + 0, G_MAXUINT32, 1, GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); @@ -1948,7 +1948,7 @@ register_item_procs (GimpPDB *pdb) g_param_spec_uint ("tattoo", "tattoo", "The new item tattoo", - 1, G_MAXUINT32, 1, + 0, G_MAXUINT32, 1, GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); diff --git a/pdb/app.pl b/pdb/app.pl index fec21aadae..e769e8b434 100644 --- a/pdb/app.pl +++ b/pdb/app.pl @@ -467,7 +467,7 @@ CODE g_param_spec_uint ("$name", "$nick", "$blurb", - 1, G_MAXUINT32, 1, + 0, G_MAXUINT32, 1, $flags) CODE } @@ -476,7 +476,7 @@ CODE g_param_spec_uint ("$name", "$nick", "$blurb", - 1, G_MAXUINT32, 1, + 0, G_MAXUINT32, 1, $flags) CODE } @@ -485,7 +485,7 @@ CODE g_param_spec_uint ("$name", "$nick", "$blurb", - 1, G_MAXUINT32, 1, + 0, G_MAXUINT32, 1, $flags) CODE }