de en es fr
Let the machine help
Light teasing, exhibition, BDSM, sissyfication, watersports... with sounds and pictures


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Bug in setImage
PostPosted: Mon Jun 12, 2017 2:30 pm 
Offline
Shy
User avatar
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")


Top
 Profile Send private message 
 
 Re: Bug in setImage
PostPosted: Mon Jun 12, 2017 8:01 pm 
Offline
Site Admin
User avatar
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.


Top
 Profile Send private message 
 
 Re: Bug in setImage
PostPosted: Tue Jun 13, 2017 12:56 am 
Offline
Shy
User avatar
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.


Top
 Profile Send private message 
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Maroon Fusion theme created by Oxydo
Software, theme modifications, phpBB modification by Doti 2010 - 2020
This website uses session cookies only.