Skip to content

Commit

Permalink
Merge pull request #5335 from HoneySkull/convert_mode_button_null_ptr
Browse files Browse the repository at this point in the history
Fixes #5280 NPE updating 'convert mode button'
  • Loading branch information
HoneySkull authored Apr 9, 2024
2 parents bfb9dc7 + 1de6181 commit 6ef3626
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions megamek/src/megamek/client/ui/swing/MovementDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -2782,9 +2782,13 @@ private void updateTraitorButton() {
}

private void updateConvertModeButton() {
if (cmd.length() > 0 && cmd.getLastStep().getType() != MoveStepType.CONVERT_MODE) {
setModeConvertEnabled(false);
return;
// Issue #5280 NPE - make sure the move path is valid and the last step isn't null.
// MovePath::getLastStep() can return null.
if ((cmd != null) && (cmd.getLastStep() != null)) {
if (cmd.length() > 0 && cmd.getLastStep().getType() != MoveStepType.CONVERT_MODE) {
setModeConvertEnabled(false);
return;
}
}

final Entity ce = ce();
Expand Down

0 comments on commit 6ef3626

Please sign in to comment.