This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 9 - Pages: 1 - Last Post: 16 Dec 24, 07:27 Last Post By: JeffTucker Threads: [ Previous | Next ]
jorsh

Posts: 14
Registered: 15-Sep-2024
Groovy exception when running "Correct image orientation" external tool
Posted: 7 Dec 24, 04:36
 
  Click to reply to this thread Reply
Windows 10, first observed with jAlbum 35. Confirmed with installing 36.

I was struggling with my own groovy script, so I tried one provided with jAlbum installation.

When trying to run unmodified "Correct image orientation" groovy script from 35 and 36 installations I am getting "groovy.lang.MissingPropertyException: No such property: processCount" exception.

After some troubleshooting I was able to strip script to a very simple code to reproduce an issue:

/* This script corrects the orientation of images that haven't been rotated properly by some software */
 
import se.datadosen.jalbum.*;
import se.datadosen.component.*;
 
var processCount = 0;
 
void processFolder(AlbumObject folder) {
        processCount++;
}
 
// Execution starts here
msg =
"This script corrects the orientation of images that haven't been rotated properly by some software";
 
processFolder(rootFolder);


Error will go away if I comment out
//processCount++;


After some Googling it seems be a known issue with certain groovy versions. The same code runs fine when changed from *.groovy to *.bsh
RobM

Posts: 3,944
Registered: 4-Aug-2006
Re: Groovy exception when running "Correct image orientation" external tool
Posted: 7 Dec 24, 11:02   in response to: jorsh in response to: jorsh
 
  Click to reply to this thread Reply
Change var processCount = 0;
To
processCount = 0;
davidekholm

Posts: 3,561
Registered: 18-Oct-2002
Re: Groovy exception when running "Correct image orientation" external tool
Posted: 7 Dec 24, 11:24   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
... or even better:
int processCount = 0;
jorsh

Posts: 14
Registered: 15-Sep-2024
Re: Groovy exception when running "Correct image orientation" external tool
Posted: 14 Dec 24, 05:52   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
Changing var to int does not work. Using variable without var or int works fine.

The explanation is here:

https://stackoverflow.com/questions/42116876/groovy-method-cannot-access-variable-in-enclosing-scope/42117033#42117033

https://stackoverflow.com/questions/6305910/how-do-i-create-and-access-the-global-variables-in-groovy

It seems this is a groovy problem and I just want make sure standard scripts shipped with jAlbum will work "out of the box".
RobM

Posts: 3,944
Registered: 4-Aug-2006
Re: Groovy exception when running "Correct image orientation" external tool
Posted: 14 Dec 24, 09:29   in response to: jorsh in response to: jorsh
 
  Click to reply to this thread Reply
jorsh wrote:
Changing var to int does not work. Using variable without var or int works fine.

The explanation is here:

https://stackoverflow.com/questions/42116876/groovy-method-cannot-access-variable-in-enclosing-scope/42117033#42117033

https://stackoverflow.com/questions/6305910/how-do-i-create-and-access-the-global-variables-in-groovy

It seems this is a groovy problem and I just want make sure standard scripts shipped with jAlbum will work "out of the box".

I suspect ‘force of habit’ led to this particular oversight when changing from BeanShell to Groovy. It was a lot of fun for skin developers converting to Groovy too, but worth the effort.
JeffTucker

Posts: 8,374
Registered: 31-Jan-2006
Re: Groovy exception when running "Correct image orientation" external tool
Posted: 14 Dec 24, 15:16   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
The external tools were all converted to Groovy in October, 2022. The fact that this is first time a user has reported a problem with this one suggests that almost no one ever uses it.

The handling of the scope of variables was very nonstandard in BeanShell, and many of us fell into sloppy habits. Groovy is much more like other languages. I've seen some mention of the fact that BeanShell 3, if it's ever released, will do away with the "shining through to the parent block" behavior of variables in BeanShell 2.
RobM

Posts: 3,944
Registered: 4-Aug-2006
Re: Groovy exception when running "Correct image orientation" external tool
Posted: 14 Dec 24, 17:21   in response to: jorsh in response to: jorsh
 
  Click to reply to this thread Reply
jorsh wrote:
It seems this is a groovy problem and I just want make sure standard scripts shipped with jAlbum will work "out of the box".
There is one more tool that has the same error, 'Rename slide variables.groovy'.
Lines 17, 42 and 43 all have a 'var' before the variable name.
JeffTucker

Posts: 8,374
Registered: 31-Jan-2006
Re: Groovy exception when running "Correct image orientation" external tool
Posted: 14 Dec 24, 17:44   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
Another good example of a tool that no one uses. I'm struggling to think of a use case for it. For the typical user, this would just be a way to cause all kinds of problems.
jorsh

Posts: 14
Registered: 15-Sep-2024
Re: Groovy exception when running "Correct image orientation" external tool
Posted: 16 Dec 24, 05:31   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
So, why not take out these tools of the list to avoid confusion? :)
JeffTucker

Posts: 8,374
Registered: 31-Jan-2006
Re: Groovy exception when running "Correct image orientation" external tool
Posted: 16 Dec 24, 07:27   in response to: jorsh in response to: jorsh
 
  Click to reply to this thread Reply
That's what I would do - quietly remove some tools from the next release, and wait to see if anyone even notices. Perhaps keep them available as a user-installed option, for the handful of people who might want them.

I'm always in favor of removing bloat from software. But convincing David to do so is always a struggle. ;)
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums