Skip to content

Commit 205502a

Browse files
committed
Prevent double-destroy from happening. Fix phaserjs#3569 (however, Game.destroy now fails elsewhere)
1 parent 380d4af commit 205502a

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/data/DataManager.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ var DataManager = new Class({
9292
*/
9393
this._frozen = false;
9494

95-
this.events.once('destroy', this.destroy, this);
95+
if (this.events)
96+
{
97+
this.events.once('destroy', this.destroy, this);
98+
}
9699
},
97100

98101
/**

src/data/DataManagerPlugin.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var DataManagerPlugin = new Class({
3030

3131
function DataManagerPlugin (scene)
3232
{
33-
DataManager.call(this, this.scene, scene.sys.events);
33+
DataManager.call(this, scene, scene.sys.events);
3434

3535
/**
3636
* [description]
@@ -64,7 +64,12 @@ var DataManagerPlugin = new Class({
6464
*/
6565
start: function ()
6666
{
67-
this.events = this.scene.sys.events;
67+
if (this.events)
68+
{
69+
this.events.off('destroy', this.destroy, this);
70+
}
71+
72+
this.events = this.systems.events;
6873

6974
var eventEmitter = this.systems.events;
7075

@@ -98,7 +103,7 @@ var DataManagerPlugin = new Class({
98103
{
99104
DataManager.prototype.destroy.call(this);
100105

101-
this.scene.sys.events.off('start', this.start, this);
106+
this.systems.events.off('start', this.start, this);
102107

103108
this.scene = null;
104109
this.systems = null;

0 commit comments

Comments
 (0)