Fixed issue with UpdateList trying to destroy items it manages.

This commit is contained in:
photonstorm 2017-08-07 17:14:13 +01:00
parent e96fe93b12
commit e19e9758f5
3 changed files with 32 additions and 18 deletions

View file

@ -1,4 +1,4 @@
var CHECKSUM = {
build: '6e590ff0-794e-11e7-8dad-3daa405d7eb2'
build: '3d87a5a0-7b8b-11e7-b495-ad4ce45c1958'
};
module.exports = CHECKSUM;

View file

@ -70,13 +70,18 @@ var GameObject = new Class({
destroy: function ()
{
this.parent.remove(this);
if (this.parent)
{
this.parent.remove(this);
}
if (this.input)
{
this.scene.sys.inputManager.clear(this);
}
this.active = false;
this.scene = undefined;
}

View file

@ -69,25 +69,34 @@ var UpdateList = new Class({
}
},
remove: function (child)
{
var index = this._list.indexOf(child);
if (index !== -1)
{
this._list.splice(index, 1);
}
return child;
},
removeAll: function ()
{
var i = this._list.length;
while (i--)
{
this.remove(this._list[i]);
}
return this;
},
// Scene that owns this Clock is shutting down
shutdown: function ()
{
var i;
for (i = 0; i < this._pendingInsertion.length; i++)
{
this._pendingInsertion[i].destroy();
}
for (i = 0; i < this._list.length; i++)
{
this._list[i].destroy();
}
for (i = 0; i < this._pendingRemoval.length; i++)
{
this._pendingRemoval[i].destroy();
}
this.removeAll();
this._list.length = 0;
this._pendingRemoval.length = 0;