Re: Bug in sigslot when disconnecting a slot

Alex Russell <[email protected]> Fri, 27 Aug 2004 23:30:58 -0700
Newsgroups gmane.comp.windows.devel.netwindows
Organization netWindows.org
Message-ID <[email protected]>
=2D----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hey Darren,

So the rmSlot method was used in sigslot_core.js, but isn't used any=20
more in the current sigslot implementation which is contained in=20
sigslot_core2.js.

Let me know where you got the old library (the stand-alone library?)=20
and if you have tried the same thing against the most recent=20
sigslot_core2.js. I expect the bug no longer exists, but it would be=20
good to verify.

Regards

On Friday 27 August 2004 5:20 pm, Darren Hobbs wrote:
> The sigslot framework appears to have a bug in the rmSlot method
> where it doesn't remove the correct slot.  I've included a version
> that addresses the issue.  The reassignment of the slots array
> removes any 'holes'.  Not knowing enough about javascript's memory
> management, this step may not be needed - the code works fine
> without it, as it leaves empty array entries as 'undefined' which
> always fail the equality check.
>
> Regards,
>
> -Darren
>
> this.rmSlot =3D function(pobj, pfp){
>             if(__sig__.isSigFP(pfp)){
>                   var tslot =3D __sig__.getSig(pfp);
>                   var tsl =3D this.slots.length;
>                   for(var x=3D(tsl-1); x>=3D0; x-=3D1){
>                         if(this.slots[x]=3D=3Dtslot){
>                               // Fix bug
>                               delete this.slots[x];
>
>                               // if only 2 arguments were passed,
> or the third isn't "true", return.
>  if((arguments.length<3)||(arguments[2]!=3Dtrue)){
>                                                 // changed 'return
> true' to break
>                                     break;
>                               }
>                         }
>                   }
>                   // Reassign slots to remove empty entries
>                   var newSlots =3D [];
>                   var m =3D 0;
>                   for (var n=3D0; n < this.slots.length; n++) {
>                         if (this.slots[n] !=3D undefined) {
>                               newSlots[m++] =3D this.slots[n];
>                         }
>                   }
>                   this.slots =3D newSlots;
>                   // End of slot reassignment
>
>                   return true;
>             }else{
>                   return false;
>             }
>       }

=2D --=20
Alex Russell
[email protected]   BD10 7AFC 87F6 63F9 1691 83FA 9884 3A15 AFC9 61B7
[email protected] F687 1964 1EF6 453E 9BD0 5148 A15D 1D43 AB92 9A46
=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)

iD8DBQFBMCajoV0dQ6uSmkYRAg9qAJ4uGbh/FR5a06PrCDct+yB5prDpFwCgr0/n
7mtOqxdkV90BOSknVkC76bo=3D
=3DSfvT
=2D----END PGP SIGNATURE-----


_______________________________________________
The netWindows developers list: [email protected]
http://netwindows.org/mailman/listinfo/devel_netwindows.org