Skip to content

Commit e19e975

Browse files
committed
Fixed issue with UpdateList trying to destroy items it manages.
1 parent e96fe93 commit e19e975

3 files changed

Lines changed: 27 additions & 13 deletions

File tree

v3/src/checksum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var CHECKSUM = {
2-
build: '6e590ff0-794e-11e7-8dad-3daa405d7eb2'
2+
build: '3d87a5a0-7b8b-11e7-b495-ad4ce45c1958'
33
};
44
module.exports = CHECKSUM;

v3/src/gameobjects/GameObject.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,18 @@ var GameObject = new Class({
7070

7171
destroy: function ()
7272
{
73-
this.parent.remove(this);
73+
if (this.parent)
74+
{
75+
this.parent.remove(this);
76+
}
7477

7578
if (this.input)
7679
{
7780
this.scene.sys.inputManager.clear(this);
7881
}
7982

83+
this.active = false;
84+
8085
this.scene = undefined;
8186
}
8287

v3/src/plugins/UpdateList.js

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,35 @@ var UpdateList = new Class({
6969
}
7070
},
7171

72-
// Scene that owns this Clock is shutting down
73-
shutdown: function ()
72+
remove: function (child)
7473
{
75-
var i;
74+
var index = this._list.indexOf(child);
7675

77-
for (i = 0; i < this._pendingInsertion.length; i++)
76+
if (index !== -1)
7877
{
79-
this._pendingInsertion[i].destroy();
78+
this._list.splice(index, 1);
8079
}
80+
81+
return child;
82+
},
8183

82-
for (i = 0; i < this._list.length; i++)
83-
{
84-
this._list[i].destroy();
85-
}
84+
removeAll: function ()
85+
{
86+
var i = this._list.length;
8687

87-
for (i = 0; i < this._pendingRemoval.length; i++)
88+
while (i--)
8889
{
89-
this._pendingRemoval[i].destroy();
90+
this.remove(this._list[i]);
9091
}
9192

93+
return this;
94+
},
95+
96+
// Scene that owns this Clock is shutting down
97+
shutdown: function ()
98+
{
99+
this.removeAll();
100+
92101
this._list.length = 0;
93102
this._pendingRemoval.length = 0;
94103
this._pendingInsertion.length = 0;

0 commit comments

Comments
 (0)