checked for null in menubar

This commit is contained in:
Oystein 2021-04-07 06:51:30 +02:00
parent be748d9138
commit 06397cc6cf

View File

@ -96,10 +96,13 @@ public class MenubarController implements Initializable, Controller {
Stage stage = (Stage) menubar.getScene().getWindow(); Stage stage = (Stage) menubar.getScene().getWindow();
File chosenFile = fc.showOpenDialog(stage); 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(); Stage stage = (Stage) menubar.getScene().getWindow();
File chosenDir = dc.showDialog(stage); File chosenDir = dc.showDialog(stage);
String correctFormat = chosenDir.getAbsolutePath().replace("\\", "\\\\"); if (chosenDir != null) {
String correctFormat = chosenDir.getAbsolutePath().replace("\\", "\\\\");
Model.setProjectPath(chosenDir.toPath()); Model.setProjectPath(chosenDir.toPath());
this.eventBus.post(new OpenProjectEvent(correctFormat)); this.eventBus.post(new OpenProjectEvent(correctFormat));
}
} }