diff --git a/app/src/main/java/gui/widget/SudokuRenderer.java b/app/src/main/java/gui/widget/SudokuRenderer.java index 3f228fc..d401b65 100644 --- a/app/src/main/java/gui/widget/SudokuRenderer.java +++ b/app/src/main/java/gui/widget/SudokuRenderer.java @@ -71,24 +71,28 @@ public class SudokuRenderer { private void renderPopup() { if (ImGui.beginPopup("editPopup")) { - Block block = currentCell.getBlock(); - int symbolCount = block.getCells().size(); - for (int i = 0; i < symbolCount; i++) { - if ((i + 1) % (int) (Math.sqrt(symbolCount)) != 1) - ImGui.sameLine(); - if (currentCell.getSymbolIndex() == i) { - if (ImGui.button("X", cellSize)) { - currentCell.setSymbolIndex(Cell.NOSYMBOL); - this.onCellChange.emit(currentCell); - ImGui.closeCurrentPopup(); - } - } else { - if (ImGui.button(Options.Symboles.getSymbols().get(i), cellSize)) { - currentCell.setSymbolIndex(i); - this.onCellChange.emit(currentCell); - if (this.doku.getDoku().isSolved()) - this.onResolve.emit(); - ImGui.closeCurrentPopup(); + if (currentCell == null) + ImGui.closeCurrentPopup(); + else { + Block block = currentCell.getBlock(); + int symbolCount = block.getCells().size(); + for (int i = 0; i < symbolCount; i++) { + if ((i + 1) % (int) (Math.sqrt(symbolCount)) != 1) + ImGui.sameLine(); + if (currentCell.getSymbolIndex() == i) { + if (ImGui.button("X", cellSize)) { + currentCell.setSymbolIndex(Cell.NOSYMBOL); + this.onCellChange.emit(currentCell); + ImGui.closeCurrentPopup(); + } + } else { + if (ImGui.button(Options.Symboles.getSymbols().get(i), cellSize)) { + currentCell.setSymbolIndex(i); + this.onCellChange.emit(currentCell); + if (this.doku.getDoku().isSolved()) + this.onResolve.emit(); + ImGui.closeCurrentPopup(); + } } } }