Skip to content

Commit

Permalink
Merge pull request #4754 from kwvanderlinde/bugfix/4523-npe-when-adju…
Browse files Browse the repository at this point in the history
…st-grid-is-open-and-map-disappears

Handle NPE when grid tool is open and map is removed
  • Loading branch information
cwisniew authored Apr 16, 2024
2 parents 7d3411e + e0ac253 commit 25ab0cd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -536,9 +536,13 @@ private void handle(SetZoneGridSizeMsg msg) {
int color = msg.getColor();

var zone = MapTool.getCampaign().getZone(zoneGUID);
zone.getGrid().setSize(size);
zone.getGrid().setOffset(xOffset, yOffset);
zone.setGridColor(color);
// Sometimes these messages can come in as a zone is being removed, so we can't rely on
// its existence
if (zone != null) {
zone.getGrid().setSize(size);
zone.getGrid().setOffset(xOffset, yOffset);
zone.setGridColor(color);
}

MapTool.getFrame().refresh();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,12 @@ private void handle(SetZoneGridSizeMsg msg) {
EventQueue.invokeLater(
() -> {
Zone zone = server.getCampaign().getZone(GUID.valueOf(msg.getZoneGuid()));
Grid grid = zone.getGrid();
grid.setSize(msg.getSize());
grid.setOffset(msg.getXOffset(), msg.getYOffset());
zone.setGridColor(msg.getColor());
if (zone != null) {
Grid grid = zone.getGrid();
grid.setSize(msg.getSize());
grid.setOffset(msg.getXOffset(), msg.getYOffset());
zone.setGridColor(msg.getColor());
}
});
}

Expand Down

0 comments on commit 25ab0cd

Please sign in to comment.