script-fu: fix #10279 gimp-image-set-selected-layers is failing

Recently some extra input validation was added, which caused the
gimp-image-set-selected-layers command in script-fu to fail with an
invalid value for argument 2.

This is caused by the object array contents always being set as
GIMP_TYPE_DRAWABLE, while the actual type may be a layer, etc.

So, let's set the actual type of drawable being used here by using
G_OBJECT_TYPE on the first data element.
This commit is contained in:
Jacob Boerema 2023-12-01 15:28:43 -05:00
parent bd398d5cff
commit c2ecf37923

View file

@ -73,6 +73,7 @@ marshal_vector_to_drawable_array (scheme *sc,
GimpDrawable **drawable_array;
gint id;
pointer error;
GType actual_type = GIMP_TYPE_DRAWABLE;
guint num_elements = sc->vptr->vector_length (vector);
g_debug ("vector has %d elements", num_elements);
@ -100,10 +101,15 @@ marshal_vector_to_drawable_array (scheme *sc,
g_free (drawable_array);
return error;
}
/* Parameters are validated based on the actual type inside the object
array. So we set that type here instead of a generic drawable. */
if (j == 0)
actual_type = G_OBJECT_TYPE (drawable_array[j]);
}
/* Shallow copy. */
gimp_value_set_object_array (value, GIMP_TYPE_DRAWABLE, (GObject**)drawable_array, num_elements);
gimp_value_set_object_array (value, actual_type, (GObject**)drawable_array, num_elements);
g_free (drawable_array);