Skip to content

Commit

Permalink
Fix NPE in PlacementPicker. (#12602)
Browse files Browse the repository at this point in the history
Make placements field never null.

Fixes #12589.
  • Loading branch information
asvitkine authored May 28, 2024
1 parent 73ce5c7 commit 577719f
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private final class PlacementPickerFrame extends JFrame {
private final Image image;
private final JLabel locationLabel = new JLabel();
private Map<String, List<Polygon>> polygons = new HashMap<>();
private Map<String, Tuple<List<Point>, Boolean>> placements;
private Map<String, Tuple<List<Point>, Boolean>> placements = new HashMap<>();
private List<Point> currentPlacements;
private boolean currentOverflowToLeft = false;
private String currentCountry;
Expand Down Expand Up @@ -569,7 +569,7 @@ private void mouseEvent(final Point point, final boolean ctrlDown, final boolean
if (!rightMouse && !ctrlDown) {
currentCountry = ToolsUtil.findTerritoryName(point, polygons).orElse("there be dragons");
// If there isn't an existing array, create one
if (placements == null || placements.get(currentCountry) == null) {
if (placements.get(currentCountry) == null) {
currentPlacements = new ArrayList<>();
currentOverflowToLeft = false;
} else {
Expand All @@ -583,10 +583,6 @@ private void mouseEvent(final Point point, final boolean ctrlDown, final boolean
}
} else if (ctrlDown) {
if (currentPlacements != null) {
// If there isn't an existing hashmap, create one
if (placements == null) {
placements = new HashMap<>();
}
placements.put(currentCountry, Tuple.of(currentPlacements, currentOverflowToLeft));
currentPlacements = new ArrayList<>();
log.info("done:" + currentCountry);
Expand Down

0 comments on commit 577719f

Please sign in to comment.