Skip to content

Commit 14a6864

Browse files
committed
If you called Scene.destroy within a Game Object pointerdown or pointerup handler, it would cause the error "Cannot read property 'game' of null" if the event wasn't cancelled in your handler. It now checks if the manager is still there before accessing its property. Fix phaserjs#4436
1 parent aad9d38 commit 14a6864

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
* `Pointer.getDuration` would return a negative / static value on desktop, or NaN on mobile, because the base time wasn't being pulled in from the Input Manager properly. Fix #4612 (thanks @BobtheUltimateProgrammer)
5151
* `Pointer.downTime`, `Pointer.upTime` and `Pointer.moveTime` would be set to NaN on mobile browsers where Touch.timeStamp didn't exist. Fix #4612 (thanks @BobtheUltimateProgrammer)
5252
* `WebGLRenderer.setScissor` will default the `drawingBufferHeight` if no argument is provided, stopping NaN scissor heights.
53+
* If you called `Scene.destroy` within a Game Object `pointerdown` or `pointerup` handler, it would cause the error "Cannot read property 'game' of null" if the event wasn't cancelled in your handler. It now checks if the manager is still there before accessing its property. Fix #4436 (thanks @jcyuan)
5354

5455
### Examples, Documentation and TypeScript
5556

src/input/InputPlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ var InputPlugin = new Class({
969969
}
970970

971971
// If they released outside the canvas, but pressed down inside it, we'll still dispatch the event.
972-
if (!aborted)
972+
if (!aborted && this.manager)
973973
{
974974
if (pointer.downElement === this.manager.game.canvas)
975975
{
@@ -1921,7 +1921,7 @@ var InputPlugin = new Class({
19211921
}
19221922

19231923
// If they released outside the canvas, but pressed down inside it, we'll still dispatch the event.
1924-
if (!aborted)
1924+
if (!aborted && this.manager)
19251925
{
19261926
if (pointer.upElement === this.manager.game.canvas)
19271927
{

0 commit comments

Comments
 (0)