Skip to content

Commit

Permalink
Merge pull request #4239 from kwvanderlinde/bugfix/4238-npe-MacroEdit…
Browse files Browse the repository at this point in the history
…orDialog-cancel

Ensure MacroEditorDialog.callback is not null
  • Loading branch information
cwisniew authored Aug 14, 2023
2 parents b570021 + ad21eba commit 2229ec5
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public class MacroEditorDialog extends JDialog implements SearchListener {
* @return the MacroEditorDialog.
*/
public static MacroEditorDialog createMacroButtonDialog() {
return new MacroEditorDialog(false, true, null);
return new MacroEditorDialog(false, true, s -> {});
}

/**
Expand All @@ -127,7 +127,8 @@ public static MacroEditorDialog createModalDialog(@Nonnull Consumer<String> call
return new MacroEditorDialog(true, false, callback);
}

private MacroEditorDialog(boolean isModal, boolean isMacroButton, Consumer<String> callback) {
private MacroEditorDialog(
boolean isModal, boolean isMacroButton, @Nonnull Consumer<String> callback) {
super(MapTool.getFrame(), "", true);
if (!isModal) {
this.setModalityType(ModalityType.MODELESS);
Expand Down Expand Up @@ -740,9 +741,7 @@ protected void executeAction() {

private void save(boolean closeDialog) {
if (button == null) {
if (callback != null) {
callback.accept(getCommandTextArea().getText());
}
callback.accept(getCommandTextArea().getText());
} else {
String hotKey = getHotKeyCombo().getSelectedItem().toString();
button.getHotKeyManager().assignKeyStroke(hotKey);
Expand Down

0 comments on commit 2229ec5

Please sign in to comment.