From 06397cc6cf8b0c13024b38dcc35b029059deb3d1 Mon Sep 17 00:00:00 2001 From: Oystein Date: Wed, 7 Apr 2021 06:51:30 +0200 Subject: [PATCH] checked for null in menubar --- .../app/controllers/MenubarController.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/app/controllers/MenubarController.java b/src/main/java/app/controllers/MenubarController.java index 7bdf358..bb0561c 100644 --- a/src/main/java/app/controllers/MenubarController.java +++ b/src/main/java/app/controllers/MenubarController.java @@ -96,10 +96,13 @@ public class MenubarController implements Initializable, Controller { Stage stage = (Stage) menubar.getScene().getWindow(); File chosenFile = fc.showOpenDialog(stage); - String correctFormat = chosenFile.getAbsolutePath().replace("\\", "\\\\"); + if (chosenFile != null) { + String correctFormat = chosenFile.getAbsolutePath().replace("\\", "\\\\"); + + Model.setActiveFilePath(chosenFile.toPath()); + this.eventBus.post(new FileSelectedEvent(correctFormat)); + } - Model.setActiveFilePath(chosenFile.toPath()); - this.eventBus.post(new FileSelectedEvent(correctFormat)); } /** @@ -112,10 +115,13 @@ public class MenubarController implements Initializable, Controller { Stage stage = (Stage) menubar.getScene().getWindow(); File chosenDir = dc.showDialog(stage); - String correctFormat = chosenDir.getAbsolutePath().replace("\\", "\\\\"); + if (chosenDir != null) { + String correctFormat = chosenDir.getAbsolutePath().replace("\\", "\\\\"); - Model.setProjectPath(chosenDir.toPath()); - this.eventBus.post(new OpenProjectEvent(correctFormat)); + Model.setProjectPath(chosenDir.toPath()); + this.eventBus.post(new OpenProjectEvent(correctFormat)); + + } }