Issue #6026 scriptfu fixup deprecated api for gimp-edit-copy etc., multi-layer
About the MR
This palliates #6026 (closed). By palliate, I mean fixes in a non-obvious way. The obvious way is to just fix many scripts, and require third parties to do so also.
It is another solution not discussed in #6026 (closed) thread. The solution adds code to Scriptfu marshalling to make it adapt
- from single Int ID arguments supplied by an author in a Scheme script
- to a pair of arguments [Int 1, GimpObjectArray] passed to the PDB
Similar to the way that PyGObject adapts a Python list to [Int, GimpObjectArray]. But slightly different, it is a "fixup" in that it adapts (in Scheme language):
- an old API e.g. ( gimp-edit-copy Int-id-of-drawable)
- where a new API is required e.g. (gimp-edit-copy Int-id-length (vector Int-id-of-drawable) )
There is one slight drawback. For the script construct '(gimp-edit-copy 1 "foo")', the fixup will succeed and Scriptfu will print two warnings:
- that a GimpObjectArray was expected
- that "foo" is extra arg and discarded; it is always an error, but the warnings might be confusing.
To clarify the cases:
- (gimp-edit-copy 1 (vector drawable)) is typical correct language to match the new signature of gimp-edit-copy, where "drawable" is a bound variable
- (gimp-edit-copy 1 '#(2)) is correct language to match the new signature of gimp-edit-copy, but non-typical where the script uses a constant ID of 2
- (gimp-edit-copy drawable) is typical language in use today using the old signature, that will be fixed up
- (gimp-edit-copy 2) is language that will be fixed up to mean: use drawable with ID 2
- (gimp-edit-copy 1 "foo") is language that will unfortunately be fixed up to mean: use drawable with ID 1 discarding the "foo"
- (gimp-edit-copy 1 '#("foo")) is a language error, "foo" is a string, it does not evaluate to the required Scheme numeric
- (gimp-edit-copy 1 (2)) is a language error, (2) is not a vector, it is an illegal function call since the list is not quoted and since "2" is not a named function
Discussion
I advocate this solution because:
- it provides backward compatibility
- it is easy to retract (its in one commit)
- its small, easily understood and maintained
If this MR is accepted, then many GIMP scripts are back to a working state. It fixes a few of the remaining breakages in GIMP's scripts.
Which might mean that 2.99.x could be used by more people, and we get more beta-testers to find other errors. Without this MR, some beta testers will find that their third party scripts don't work and stop using 2.99.x.
Personally, I would prefer a different solution discussed in the #6026 (closed) thread,
- revert the API change for gimp-edit-copy
- and add a new PDB procedure gimp-edit-copy-multiple
That solution would have nearly the same effect as this MR.
Testing
I haven't tested it much, only enough to know it seems to work. Because it is only one proposed solution, that I doubt will be chosen.
Note the branch is branched from my previous MR, still pending.