Skip to content

Commit

Permalink
Fix NPE when opening a non existing file from the recent files menu
Browse files Browse the repository at this point in the history
dialogService object was null, because the FileHistoryMenu class is initialized before the ctor of JabRef frame creates the dialog service object
  • Loading branch information
Siedlerchr committed Sep 20, 2019
1 parent db96f88 commit 8af0503
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an error where the number of matched entries shown in the group pane was not updated correctly. [#4441](https://github.com/JabRef/jabref/issues/4441)
- We fixed an error mentioning "javafx.controls/com.sun.javafx.scene.control" that was thrown when interacting with the toolbar.
- We fixed an error where a cleared search was restored after switching libraries. [#4846](https://github.com/JabRef/jabref/issues/4846)
- We fixed an exception which occured when trying to open a non existing file from the "Recent files"-menu [#5334](https://github.com/JabRef/jabref/issues/5334)


### Removed

Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/jabref/gui/menus/FileHistoryMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ public class FileHistoryMenu extends Menu {
private final FileHistory history;
private final JabRefFrame frame;
private final JabRefPreferences preferences;
private final DialogService dialogService;

public FileHistoryMenu(JabRefPreferences preferences, JabRefFrame frame) {
setText(Localization.lang("Recent libraries"));

this.frame = frame;
this.preferences = preferences;
this.dialogService = frame.getDialogService();
history = preferences.getFileHistory();
if (history.isEmpty()) {
setDisable(true);
Expand Down Expand Up @@ -63,7 +61,7 @@ public void storeHistory() {

public void openFile(Path file) {
if (!Files.exists(file)) {
dialogService.showErrorDialogAndWait(
frame.getDialogService().showErrorDialogAndWait(
Localization.lang("File not found"),
Localization.lang("File not found") + ": " + file);
history.removeItem(file);
Expand Down

0 comments on commit 8af0503

Please sign in to comment.