v0.6.3a: fixed various rare crashes with the alchemy window

This commit is contained in:
Evan Debenham
2018-02-19 13:50:31 -05:00
parent 6d53f238bc
commit 8d09f897a5
@@ -86,6 +86,7 @@ public class WndAlchemy extends Window {
h += desc.height() + 6; h += desc.height() + 6;
synchronized (inputs) {
for (int i = 0; i < inputs.length; i++) { for (int i = 0; i < inputs.length; i++) {
inputs[i] = new WndBlacksmith.ItemButton() { inputs[i] = new WndBlacksmith.ItemButton() {
@Override @Override
@@ -105,6 +106,7 @@ public class WndAlchemy extends Window {
add(inputs[i]); add(inputs[i]);
h += BTN_SIZE + 2; h += BTN_SIZE + 2;
} }
}
btnCombine = new RedButton(""){ btnCombine = new RedButton(""){
Image arrow; Image arrow;
@@ -211,7 +213,8 @@ public class WndAlchemy extends Window {
protected WndBag.Listener itemSelector = new WndBag.Listener() { protected WndBag.Listener itemSelector = new WndBag.Listener() {
@Override @Override
public void onSelect( Item item ) { public void onSelect( Item item ) {
if (item != null) { synchronized (inputs) {
if (item != null && inputs[0] != null) {
for (int i = 0; i < inputs.length; i++) { for (int i = 0; i < inputs.length; i++) {
if (inputs[i].item == null) { if (inputs[i].item == null) {
if (item instanceof Dart) { if (item instanceof Dart) {
@@ -222,9 +225,10 @@ public class WndAlchemy extends Window {
break; break;
} }
} }
}
updateState(); updateState();
} }
}
}
}; };
private<T extends Item> ArrayList<T> filterInput(Class<? extends T> itemClass){ private<T extends Item> ArrayList<T> filterInput(Class<? extends T> itemClass){
@@ -276,8 +280,9 @@ public class WndAlchemy extends Window {
Dungeon.level.drop(result, Dungeon.hero.pos); Dungeon.level.drop(result, Dungeon.hero.pos);
} }
synchronized (inputs) {
for (int i = 0; i < inputs.length; i++) { for (int i = 0; i < inputs.length; i++) {
if (inputs[i].item != null) { if (inputs[i] != null && inputs[i].item != null) {
if (inputs[i].item.quantity() <= 0) { if (inputs[i].item.quantity() <= 0) {
inputs[i].slot.item(new WndBag.Placeholder(ItemSpriteSheet.SOMETHING)); inputs[i].slot.item(new WndBag.Placeholder(ItemSpriteSheet.SOMETHING));
inputs[i].item = null; inputs[i].item = null;
@@ -286,6 +291,7 @@ public class WndAlchemy extends Window {
} }
} }
} }
}
btnCombine.enable(false); btnCombine.enable(false);
} }