[Laszlo-dev] For Review: Change 20061103-Philip-8 Summary: Timer function must check element because it might have been deleted.

Max Carlson max at openlaszlo.org
Sat Nov 4 11:07:53 PST 2006


I don't think the call to __DiscardImage is required - it should have 
been called by LzPool.destroy() anyhow...  Looks good!

-Max

Philip Romanik wrote:
> Hi Max,
> 
> You and I made the same changes, except that I have one additional 
> change that you recommended earlier today. Can you check this patch and 
> see if it is needed.
> 
> Thanks!
> 
> Phil
> 
> 
> $ svn diff LzSprite.js
> Index: LzSprite.js 
> ===================================================================
> --- LzSprite.js (revision 2383)
> +++ LzSprite.js (working copy)
> @@ -667,13 +667,15 @@
> 
>  // These three methods are called by the image pool
>  LzSprite.prototype.__destroyImage = function (img) {
> -    if (img.sizer) {
> +    if (LzSprite.prototype.quirks.ie_alpha_image_loader && img.sizer) {
> +        if (img.sizer.tId) clearTimeout(img.sizer.tId);
>          LzSprite.prototype.__discardElement(img.sizer);
>          img.sizer.onload = null;
>          img.sizer.onloadforeal = null;
>          img.sizer = null;
>      }
>      if (img) LzSprite.prototype.__discardElement(img);
> +    img = null;
>  }
> 
>  LzSprite.prototype.__gotImage = function(url) {
> @@ -699,7 +701,7 @@
>              im.sizer.onload = function() {
>                  im.style.display = '';
>                  // This resolves all sorts of timing-related image 
> loading bugs
> 
> -                setTimeout(this.onloadforeal, 1);
> +                im.sizer.tId = setTimeout(this.onloadforeal, 1);
>              }
>              im.sizer.onloadforeal = function() {
>                  im.owner.__imgonload(im.sizer);
> @@ -789,7 +791,8 @@
>          }
>      }
>      if (this.__ImgPool) this.__ImgPool.destroy();
> -    if (this.__LZimg) this.__discardElement(this.__LZimg);
> +    if (this.__LZimg) LzSprite.prototype.__destroyImage(this.__LZimg);
> +
>      if (this.__LZclick) {
>          this.__setClickable(false, this.__LZclick);
>          this.__discardElement(this.__LZclick);
> 
> 
> 
> 
>> Here's an updated patch:
>>
>> @@ -667,13 +667,15 @@
>>
>>   // These three methods are called by the image pool
>>   LzSprite.prototype.__destroyImage = function (img) {
>> -    if (img.sizer) {
>> +    if (LzSprite.prototype.quirks.ie_alpha_image_loader && img.sizer) {
>> +        if (img.sizer.tId) clearTimeout(img.sizer.tId);
>>           LzSprite.prototype.__discardElement(img.sizer);
>>           img.sizer.onload = null;
>>           img.sizer.onloadforeal = null;
>>           img.sizer = null;
>>       }
>>       if (img) LzSprite.prototype.__discardElement(img);
>> +    img = null;
>>   }
>>
>>   LzSprite.prototype.__gotImage = function(url) {
>> @@ -699,7 +701,7 @@
>>               im.sizer.onload = function() {
>>                   im.style.display = '';
>>                   // This resolves all sorts of timing-related image
>> loading bugs-                setTimeout(this.onloadforeal, 1);
>> +                im.sizer.tId = setTimeout(this.onloadforeal, 1);
>>               }
>>               im.sizer.onloadforeal = function() {
>>                   im.owner.__imgonload(im.sizer);
>>
>> -Max
> 


More information about the Laszlo-dev mailing list