richardlord / Ash

An Actionscript 3 entity system framework for game development
http://www.richardlord.net/ash/
Other
447 stars 95 forks source link

SignalBase.removeAll() #34

Closed SergeyRomanko closed 10 years ago

SergeyRomanko commented 10 years ago

Hi!

I think there is small issue in SignalBase.removeAll() method.

This is how removeAll method looks now

        public function removeAll() : void
        {
            while( head )
            {
                var node : ListenerNode = head;
                head = head.next;
                delete nodes[ node.listener ];
                listenerNodePool.dispose( node );
                node.previous = null;
                node.next = null;
            }
            ...

And this is ListenerNodePool.dispose( node : ListenerNode ) method

        internal function dispose( node : ListenerNode ):void
        {
            node.listener = null;
            node.once = false;
            node.next = null;
            node.previous = tail;
            tail = node;
        }

I think setting node.previous should be removed from removeAll() because it could break link between list elements inside ListenerNodePool. And it is not necessary to set node.next to null in removeAll(), it is already null.