Merge pull request #84 from onedayitwillmake/dev

Fixed bug in LinkedList#remove that could cause first to point to a dead node
This commit is contained in:
Richard Davey 2013-10-01 03:01:38 -07:00
commit 3740ea05ee

View file

@ -38,37 +38,19 @@ Phaser.LinkedList.prototype = {
},
remove: function (child) {
// If the list is empty
if (this.first == null && this.last == null)
{
return;
if( this.first ) {
child.next = this.last.next;
child.prev = this.last;
if( this.last.next ) {
this.last.next.prev = child;
}
this.last.next = child;
this.last = this.last.next;
} else {
this.first = this.last = child;
}
this.total--;
// The only node?
if (this.first == child && this.last == child)
{
this.first = null;
this.last = null;
this.next = null;
child.next = null;
child.prev = null;
return;
}
var childPrev = child.prev;
// Tail node?
if (child.next)
{
// Has another node after it?
child.next.prev = child.prev;
}
childPrev.next = child.next;
},
callAll: function (callback) {