Fix crash with opening grids that are not connected (grid.getController() will be null and the synchronized stmt will fail)

This commit is contained in:
Raoul Van den Berge
2016-03-28 19:15:59 +02:00
parent 20d6cd76ed
commit 45f110acff

View File

@@ -112,7 +112,7 @@ public class GuiGrid extends GuiBase {
public void drawForeground(int mouseX, int mouseY) { public void drawForeground(int mouseX, int mouseY) {
scrollbar.update(this, mouseX, mouseY); scrollbar.update(this, mouseX, mouseY);
synchronized (grid.getController()) {
drawString(7, 7, t("gui.refinedstorage:grid")); drawString(7, 7, t("gui.refinedstorage:grid"));
if (grid.getType() == EnumGridType.CRAFTING) { if (grid.getType() == EnumGridType.CRAFTING) {
@@ -158,7 +158,7 @@ public class GuiGrid extends GuiBase {
text = String.valueOf(qty); text = String.valueOf(qty);
} }
if (hoveringSlotId == slot && GuiScreen.isShiftKeyDown()) { if (hoveringSlotId == slot && GuiScreen.isShiftKeyDown() && qty > 1) {
text = String.valueOf(qty); text = String.valueOf(qty);
} }
@@ -197,7 +197,6 @@ public class GuiGrid extends GuiBase {
drawTooltip(mouseX, mouseY, t("misc.refinedstorage:clear")); drawTooltip(mouseX, mouseY, t("misc.refinedstorage:clear"));
} }
} }
}
public List<StorageItem> getItems() { public List<StorageItem> getItems() {
List<StorageItem> items = new ArrayList<StorageItem>(); List<StorageItem> items = new ArrayList<StorageItem>();
@@ -206,6 +205,7 @@ public class GuiGrid extends GuiBase {
return items; return items;
} }
synchronized (grid.getController()) {
items.addAll(grid.getController().getItems()); items.addAll(grid.getController().getItems());
if (!searchField.getText().trim().isEmpty()) { if (!searchField.getText().trim().isEmpty()) {
@@ -254,6 +254,7 @@ public class GuiGrid extends GuiBase {
return items; return items;
} }
}
@Override @Override
public void mouseClicked(int mouseX, int mouseY, int clickedButton) throws IOException { public void mouseClicked(int mouseX, int mouseY, int clickedButton) throws IOException {