Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix async load complete when state is destroyed #410

Merged
merged 2 commits into from
Nov 30, 2017
Merged

Fix async load complete when state is destroyed #410

merged 2 commits into from
Nov 30, 2017

Conversation

clesquir
Copy link
Contributor

@clesquir clesquir commented Nov 30, 2017

This PR:

  • is a bug fix

Avoid raising this following error if state has been destroyed during async loading:

Uncaught TypeError: Cannot read property 'loadComplete' of null
    at Phaser.Loader.finishedLoading
    at Phaser.Loader.processLoadQueue
    at Phaser.Loader.asyncComplete
    at Phaser.Loader.fileComplete
    at Image.file.data.onload

Avoid raising this following error if state has been destroyed during async loading:
```
Uncaught TypeError: Cannot read property 'loadComplete' of null
    at Phaser.Loader.finishedLoading
    at Phaser.Loader.processLoadQueue
    at Phaser.Loader.asyncComplete
    at Phaser.Loader.fileComplete
    at Image.file.data.onload
```
@samme
Copy link
Collaborator

samme commented Nov 30, 2017

This would handle the case where you call game.destroy() within a state preload callback?

@samme samme added this to the 2.9.3 milestone Nov 30, 2017
@samme samme merged commit be6af07 into phaserjs:master Nov 30, 2017
@clesquir clesquir deleted the patch-1 branch November 30, 2017 19:32
@clesquir
Copy link
Contributor Author

My actual case is when the user navigates to another page while the loader has not finished. The destroy would indeed be called before this.game.state.loadComplete();.

Thanks for merging this :)

@samme
Copy link
Collaborator

samme commented Dec 7, 2017

I wonder if we should just exit immediately in Loader#finishedLoading. There's no point in continuing if the game is destroyed. Or would users expect onLoadComplete to trigger in any case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants