mirror of
https://github.com/wassname/phaser.git
synced 2026-09-11 12:31:29 +08:00
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:
+11
-29
@@ -38,37 +38,19 @@ Phaser.LinkedList.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
remove: function (child) {
|
remove: function (child) {
|
||||||
|
if( this.first ) {
|
||||||
// If the list is empty
|
child.next = this.last.next;
|
||||||
if (this.first == null && this.last == null)
|
child.prev = this.last;
|
||||||
{
|
if( this.last.next ) {
|
||||||
return;
|
this.last.next.prev = child;
|
||||||
}
|
}
|
||||||
|
this.last.next = child;
|
||||||
|
this.last = this.last.next;
|
||||||
|
} else {
|
||||||
|
this.first = this.last = child;
|
||||||
|
}
|
||||||
|
|
||||||
this.total--;
|
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) {
|
callAll: function (callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user