From daa5e662e77cbb6f4c07e75f9a75182a19b36466 Mon Sep 17 00:00:00 2001 From: David Schontzler <2080286+schontz@users.noreply.github.com> Date: Tue, 21 Dec 2021 19:55:35 -0800 Subject: [PATCH] destroy game objects during shutdown safely #5520 --- src/gameobjects/DisplayList.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/gameobjects/DisplayList.js b/src/gameobjects/DisplayList.js index c0542094a..11619af78 100644 --- a/src/gameobjects/DisplayList.js +++ b/src/gameobjects/DisplayList.js @@ -231,15 +231,11 @@ var DisplayList = new Class({ { var list = this.list; - var i = list.length; - - while (i--) + while (list.length) { - list[i].destroy(true); + list[0].destroy(true); } - list.length = 0; - this.events.off(SceneEvents.SHUTDOWN, this.shutdown, this); },