From 9ac770a140cb98f87aac9f6477f240a50eeea4bb Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 24 Jun 2022 11:52:44 -0400 Subject: [PATCH] v1.3.0: fixed toolbar instance persisting when it shouldn't --- .../shatteredpixeldungeon/ui/Toolbar.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java index 92301c1e2..95683b3aa 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java @@ -74,7 +74,13 @@ public class Toolbar extends Component { height = btnInventory.height(); } - + + @Override + public synchronized void destroy() { + super.destroy(); + if (instance == this) instance = null; + } + @Override protected void createChildren() { @@ -406,8 +412,10 @@ public class Toolbar extends Component { private static CellSelector.Listener informer = new CellSelector.Listener() { @Override public void onSelect( Integer cell ) { - instance.examining = false; - GameScene.examineCell( cell ); + if (instance != null) { + instance.examining = false; + GameScene.examineCell(cell); + } } @Override public String prompt() { @@ -527,7 +535,7 @@ public class Toolbar extends Component { @Override public synchronized void destroy() { super.destroy(); - SWAP_INSTANCE = null; + if (SWAP_INSTANCE == this) SWAP_INSTANCE = null; } @Override