Skip to content

Commit

Permalink
Exit finishedLoading() if game is destroyed
Browse files Browse the repository at this point in the history
Fixes phaserjs#666

No signals are dispatched (API change)
  • Loading branch information
samme committed May 12, 2020
1 parent bf5493e commit 9b76df4
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/loader/Loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2163,7 +2163,8 @@ Phaser.Loader.prototype = {
finishedLoading: function (abnormal)
{

if (this.hasLoaded)
// Destroy could have occurred while loading
if (this.hasLoaded || !this.game.state)
{
return;
}
Expand All @@ -2180,16 +2181,9 @@ Phaser.Loader.prototype = {

this.game.state.loadUpdate();
this.onBeforeLoadComplete.dispatch();

this.reset();

this.onLoadComplete.dispatch();

// Check if the state still exists since destroy could have occurred while loading
if (this.game.state)
{
this.game.state.loadComplete();
}
this.game.state.loadComplete();

},

Expand Down

0 comments on commit 9b76df4

Please sign in to comment.