libURL: load unload bug?

Dave Cragg dave.cragg at lacscentre.co.uk
Fri Feb 16 17:04:20 EST 2007


On 16 Feb 2007, at 20:49, David Bovill wrote:

> To confirm - issueing "libUrlResetAll" fixes the problem.
>
> But what is the problem ??? I am loading thumbnails into my  
> application
> asynchronously using the "load with message" command. As each  
> thumbnail
> comes over I get the url from the cache and put the data into the  
> thumbnail
> image finally unloading the url so as to clear the image from the  
> cache
> memory. Seems all to work fine except that every so often with  
> loads of 100
> images well the cache gets mucked up - here are the scripts:
>
> setprop image_Loaded photoURL
>    put the long id of the target into thumbView
>    load url photoURL with message "image_DisplayLoaded"
> end image_Loaded
>
> on image_DisplayLoaded someURL, someStatus
>    put url someURL into someImage
>    set the image_Value of me to someImage
>    unload url someURL
> end image_DisplayLoaded
>
> setprop image_Value someImage
>    put the short id of the image_Object of me into imageObjectID
>    put someImage into image id imageObjectID of me
> end image_Value
>
> Perhaps I am not checking the status before unloading? Should not  
> cause this
> problem but still... ?


I can't say for sure what the problem is, but you probably should  
check the status at the beginning of the image_DisplayLoaded handler.

I see a possible problem if the load has failed for some reason, and  
then you immediately do a "get url". In this case, the "get url" will  
try to retrieve the data directly from the server, and may well fail  
too as it's to the same url. Something like:

on image_DisplayLoaded someURL, someStatus
   if someStatus is "cached" then	
     put url someURL into someImage
     set the image_Value of me to someImage
     unload url someURL
   else
     unload url someURL
     ## do some error handling here
     ## error message, etc.
   end if
end image_DisplayLoaded

I'm not saying this is the problem, but it might be good to eliminate  
this possibility first.

Cheers
Dave



More information about the Use-livecode mailing list