Skip to content

Commit

Permalink
Revert fix for JabRef#8297, only focus on JabRef#8296
Browse files Browse the repository at this point in the history
  • Loading branch information
LIM0000 committed May 9, 2022
1 parent 8e2cb4a commit 3a30392
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,7 @@ public void addTab(LibraryTab libraryTab, boolean raisePanel) {
libraryTab.setOnCloseRequest(event -> {
closeTab(libraryTab);
libraryTab.getDataLoadingTask().cancel();
event.consume();
});

libraryTab.setContextMenu(createTabContextMenuFor(libraryTab, Globals.getKeyPrefs()));
Expand Down Expand Up @@ -1156,17 +1157,9 @@ private boolean confirmClose(LibraryTab libraryTab) {
dialogService.showErrorDialogAndWait(Localization.lang("Save library"), Localization.lang("Could not save file."), ex);
}
// Save was cancelled or an error occurred.
LibraryTab newLibrary = addTab(libraryTab.getBibDatabaseContext(), true);
newLibrary.changedProperty().setValue(libraryTab.isModified());
return true;
return false;
}

if (response.isPresent() && response.get().equals(cancel)) {
LibraryTab newLibrary = addTab(libraryTab.getBibDatabaseContext(), true);
newLibrary.changedProperty().setValue(libraryTab.isModified());
return true;
}
return false;
return response.isEmpty() || !response.get().equals(cancel);
}

/**
Expand Down Expand Up @@ -1206,6 +1199,11 @@ private void confirmEmptyEntry(LibraryTab libraryTab, BibDatabaseContext context
}

private void closeTab(LibraryTab libraryTab) {
// empty tab without database
if (libraryTab == null) {
return;
}

final BibDatabaseContext context = libraryTab.getBibDatabaseContext();

if (context.hasEmptyEntries()) {
Expand All @@ -1215,19 +1213,19 @@ private void closeTab(LibraryTab libraryTab) {
if (libraryTab.isModified() && (context.getLocation() == DatabaseLocation.LOCAL)) {
if (confirmClose(libraryTab)) {
removeTab(libraryTab);
} else {
return;
}
} else if (context.getLocation() == DatabaseLocation.SHARED) {
context.convertToLocalDatabase();
context.getDBMSSynchronizer().closeSharedDatabase();
context.clearDBMSSynchronizer();
removeTab(libraryTab);
return;
} else {
removeTab(libraryTab);
}
AutosaveManager.shutdown(libraryTab.getBibDatabaseContext());
BackupManager.shutdown(libraryTab.getBibDatabaseContext());
AutosaveManager.shutdown(context);
BackupManager.shutdown(context);
}

private void removeTab(LibraryTab libraryTab) {
Expand Down

0 comments on commit 3a30392

Please sign in to comment.