| SexScripts : Bug in setImage - https://ss.deviatenow.com:443/viewtopic.php?f=6&t=691 | Page 1 of 1 |
Bug in setImage |
kinkyswan [ Mon Jun 12, 2017 2:30 pm ] |
|---|---|
I've discovered a bug in the behavior of setImage; I've uploaded the script set_image_bug_demo to demonstrate (note: you'll need to create the folder set_image_bug_demo in the images folder in order for the demo to work.) Bug applies to Sexscripts 1.22 (November 7, 2016) and 1.23 (May 25, 2017) and possibly earlier releases Description of bug: When setImage is used to display a particular image file, then the script overwrites that image file on disk with new data, when a subsequent call is made to setImage, the original image file is sometimes displayed rather than the new image. Other times, the new image is displayed, but contorted to the original image's dimensions. Behavior persists across script resets as long as the same instance of Sexscripts is running. Workaround: A timestamp can be included in the filename to make it different. Unfortunately, this clutters up the folder The demo code: Code: def FOLDER_NAME = "set_image_bug_demo/"
show("") setImage(null) showButton("Demonstrate Bug in setImage") def filePath = getFile("Select a JPEG picture of a toy") new File("images/" + FOLDER_NAME + "toy.jpg").delete() new File("images/" + FOLDER_NAME + "toy.jpg") << new File(filePath).getBytes() setImage(FOLDER_NAME + "toy.jpg") showButton("original picture is showing") filePath = getFile("Select a different JPEG picture of a toy") new File("images/" + FOLDER_NAME + "toy.jpg").delete() // Note that we are deleting the original image new File("images/" + FOLDER_NAME + "toy.jpg") << new File(filePath).getBytes() // The new image is saved to disk setImage(FOLDER_NAME + "toy.jpg") // This *should* show the new image, rendered from disk, but may not showButton("new picture should be showing, but may not be, or may be distorted") filePath = getFile("Select a third JPEG picture of a toy") def timestamp = getTime() // Include timestamp in the filename to avoid the bug new File("images/" + FOLDER_NAME + "toy" + timestamp + ".jpg") << new File(filePath).getBytes() setImage(FOLDER_NAME + "toy" + timestamp + ".jpg") showButton("third picture is showing using workaround") |
|
Re: Bug in setImage |
doti [ Mon Jun 12, 2017 8:01 pm ] |
|---|---|
Thank you. This is a standard behaviour (cache from javax.swing.ImageIcon), for speed. It's better to keep it so you should, if needed, keep the strategy you chose (a different name each time) ; you delete old files also. |
|
Re: Bug in setImage |
kinkyswan [ Tue Jun 13, 2017 12:56 am ] |
|---|---|
doti wrote: This is a standard behaviour (cache from javax.swing.ImageIcon), for speed. It's better to keep it so you should, if needed, keep the strategy you chose (a different name each time) ; you delete old files also. Ah, okay. It perplexed me for a few minutes, but it's not a big deal. Thank you for the response. |
|
| Page 1 of 1 | All times are UTC + 1 hour [ DST ] |