GNOME Bugzilla – Bug 163479
SOTA Chrome Error
Last modified: 2008-01-15 12:44:59 UTC
If you leave the text field open, you will get this GIMP Message: SOTA Chrome Message Error while executing (script-fu-sota-chrome-logo -60 -47 0.75 "" 1000 "RoostHeavy" "/usr/share/gimp/2.0/scripts/images/beavis.jpg" '(211 95 0) '(0 0 0)) ERROR: Procedural database execution failed: (gimp_drawable_width -1) To make GIMP more usuable for new/unexperience users, it should just say the text field is blank.
You probably meant to write "If you leave the text field empty ...". I don't think it's surprising that the Logo scripts don't work without any text, but sure, the script (and many others) could check the return value and abort with a reasonable error message.
A quick check with grep indicates there are about 77 scripts (all the main logo scripts?) which have this problem.
yah, it just makes things more usuable for new users.
might be better to run using the default string rather than failing if the user doesn't provide any text. Kevin, do you have an idea how to do this all in one go or do you think it will probably require improving each script individually? [I think at this statge SOTA Chrome (State of the Art) is a bit of a misnomer. Acronyms suck.]
Sure, let's rename SOTA Chrome in the menus.
The scripts should really be changed to handle the fact that some calls to PDB functions could fail. In Tiny-Fu this could be done by using try/catch but in Script-Fu I think you would just have to test the string before calling a gimp-text function. A global "solution" could be used as a stop-gap measure. Using a default string would just hide an incorrect call to the gimp-text functions. Sven suggested checking to see if gimp-text was called with a zero-length string when an error but that won't work since the gimp-text routines don't return an execution error when passed a zero-length string. So instead of the script aborting if it isn't set up to handle the error, something else in the script will fail due to an earlier bad call to a gimp-text routines. I think the only other way to handle the problem is to use a Scheme based wrapper for the gimp-text routines. When calling a gimp-text routine, instead of calling the marshalling code right away, some extra Scheme code would perform a test on the text string before calling the marshalling code. This wrapper would spit out a message alerting the user to the bad call and could also abort the script.
Created attachment 38382 [details] A file containing Scheme-based wrappers for two gimp-text-* routines. The attached file contains Scheme-based wrappers for gimp-text-fontname and gimp-text-get-extents-fontname to be used with Script-Fu. Any time either of these routines is called in a script the wrapper function gets used. The wrapper then tests the passed string to see if it is empty. If it is, a warning message is displayed before passing the call to GIMP. The wrappers won't abort a script if an empty string is passed but, since the script is probably going to die later on when a call is made to get the width or height of the new layer. The user is alerted to the fact they are doing something they probably shouldn't be doing. These wrappers avoid the need to make changes to any of the 77 or so scripts which would otherwise need to be changed to fix the reported problem.
I should also point out (in case it isn't obvious) that for the attached script to work, it only needs to be copied to one of the directories which usually holds Script-Fu scripts.
How can this avoid changing the scripts? If you transparently wrap gimp-text-*, you are effectively changing the call in a not backward-compatible way. Any script that correctly checked the return value would then cause a useless and annoying warning to appear.
The only way I see to fix this issue would be to provide wrappers that the scripts can call (script-fu-text-fontname and script-fu-text-get-extents-fontname). These wrappers would have to be documented and need to provide translated error messages. All our scripts would then have to ported to these new functions. I don't think this is worth the effort; let's close this report as WONTFIX and concentrate on providing a next text API that doesn't have this flaw.