From 4dd73f025c0c52dd3913b8b56782b16ff143ee5c Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 22 Oct 2019 20:19:23 -0400 Subject: [PATCH] v0.7.5e: fixed toasts being destroyed in the actor thread --- .../shatteredpixeldungeon/scenes/GameScene.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java index d86afd0cf..f0df72975 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java @@ -99,6 +99,7 @@ import com.shatteredpixel.shatteredpixeldungeon.windows.WndTradeItem; import com.watabou.glwrap.Blending; import com.watabou.noosa.Camera; import com.watabou.noosa.Game; +import com.watabou.noosa.Gizmo; import com.watabou.noosa.Group; import com.watabou.noosa.NoosaScript; import com.watabou.noosa.NoosaScriptNoLighting; @@ -521,7 +522,11 @@ public class GameScene extends PixelScene { Actor.process(); } }; - + + //sometimes UI changes can be prompted by the actor thread. + // We queue any removed element destruction, rather than destroying them in the actor thread. + private ArrayList toDestroy = new ArrayList<>(); + @Override public synchronized void update() { if (Dungeon.hero == null || scene == null) { @@ -574,6 +579,11 @@ public class GameScene extends PixelScene { } cellSelector.enable(Dungeon.hero.ready); + + for (Gizmo g : toDestroy){ + g.destroy(); + } + toDestroy.clear(); } private boolean tagAttack = false; @@ -680,7 +690,7 @@ public class GameScene extends PixelScene { if (prompt != null) { prompt.killAndErase(); - prompt.destroy(); + toDestroy.add(prompt); prompt = null; }