Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NPE in Set Facing tool #4957

Merged
merged 2 commits into from
Oct 2, 2024

Conversation

kwvanderlinde
Copy link
Collaborator

@kwvanderlinde kwvanderlinde commented Sep 27, 2024

Identify the Bug or Feature request

Fixes #4956

Description of the Change

The Set Facing tool now handles the case where a token has no facing at the end of the operation (see changes in FacingTool.mousePressed()).

The rest of the changes are easy cleanup related to facing, but don't affect functionality:

  • Use Token.hasFacing() instead of Token.getFacing() == null
  • Use Token.getFacingInDegrees() where it helps.
  • Provide Token.removeFacing() to clear facing rather than using Token.setFacing(null).
  • Move the default -90° angle into Token.getFacing()
  • Remove all nullability of facing in Token's API.

Possible Drawbacks

None

Documentation Notes

N/A

Release Notes

  • Fixed a bug where the Set Facing tool would throw an error if the mouse never moved.

This change is Reviewable

We now handle the case where a token does not have a facing. In that case, the tool updates the other clients to also
remove the facing.
A token still may not have a facing, but this must now be determined by `Token.hasFacing()`. `Token.getFacing()` will
never return `null` but will provide the default of -90°, which removes the case work that several callers had to
consistently perform.

In order to remove a token's facing, `Token.removeFacing()` can now be used as `Token.setFacing()` no longer accepts
`null`.

Also remove some unused and redundant code in related places.
@cwisniew cwisniew added this pull request to the merge queue Oct 2, 2024
Merged via the queue into RPTools:develop with commit 59bac50 Oct 2, 2024
5 checks passed
@kwvanderlinde kwvanderlinde deleted the bugfix/4956-npe-set-facing branch October 2, 2024 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: NPE with the "Set Facing" tool
2 participants