diff --git a/CHANGELOG.md b/CHANGELOG.md index b97d56b6608..0d068702b0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,8 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - The [ACM fetcher](https://help.jabref.org/en/ACMPortal) does no longer add HTML code to the bib-file. Fixes [#2472](https://github.com/JabRef/jabref/issues/2472). - When [finding unlinked files](https://help.jabref.org/en/FindUnlinkedFiles), JabRef does not freeze any more. Fixes [#2309]()https://github.com/JabRef/jabref/issues/2309). - Collapse and expand all buttons in the group assignment dialog no longer lead to a crash of JabRef. -- The aux export command line function does no longer add duplicates of references that were resolved via `crossref`. Fixes [#2475](https://github.com/JabRef/jabref/issues/2475). +- The aux export command line function does no longer add duplicates of references that were resolved via `crossref`. Fixes [#2475](https://github.com/JabRef/jabref/issues/2475). +- When the database is changed external, JabRef is no longer prevented from an orderly shutdown. Fixes [#2486](https://github.com/JabRef/jabref/issues/2486). - Parsing of damaged metadata is now more robust and reports a more detailed error message. Fixes [#2477](https://github.com/JabRef/jabref/issues/2477). - Dynamic groups with regular expression can be edited again. Fixes [#2481](https://github.com/JabRef/jabref/issues/2481). diff --git a/src/main/java/net/sf/jabref/logic/autosaveandbackup/AutosaveManager.java b/src/main/java/net/sf/jabref/logic/autosaveandbackup/AutosaveManager.java index 65908e2c971..323358afa9b 100644 --- a/src/main/java/net/sf/jabref/logic/autosaveandbackup/AutosaveManager.java +++ b/src/main/java/net/sf/jabref/logic/autosaveandbackup/AutosaveManager.java @@ -89,6 +89,11 @@ public void registerListener(Object listener) { } public void unregisterListener(Object listener) { - eventBus.unregister(listener); + try { + eventBus.unregister(listener); + } catch (IllegalArgumentException e) { + // occurs if the event source has not been registered, should not prevent shutdown + LOGGER.debug(e); + } } } diff --git a/src/main/java/net/sf/jabref/logic/search/SearchQueryHighlightObservable.java b/src/main/java/net/sf/jabref/logic/search/SearchQueryHighlightObservable.java index d7e4144e84a..2902fa749d5 100644 --- a/src/main/java/net/sf/jabref/logic/search/SearchQueryHighlightObservable.java +++ b/src/main/java/net/sf/jabref/logic/search/SearchQueryHighlightObservable.java @@ -31,7 +31,11 @@ public void addSearchListener(SearchQueryHighlightListener newListener) { public void removeSearchListener(SearchQueryHighlightListener listener) { Objects.requireNonNull(listener); - eventBus.unregister(listener); + try { + eventBus.unregister(listener); + } catch (IllegalArgumentException e) { + // occurs if the event source has not been registered, should not prevent shutdown + } } /** * Fires an event if a search was started (or cleared) diff --git a/src/main/java/net/sf/jabref/model/database/BibDatabase.java b/src/main/java/net/sf/jabref/model/database/BibDatabase.java index b19e3a66523..fdd4e1e3cda 100644 --- a/src/main/java/net/sf/jabref/model/database/BibDatabase.java +++ b/src/main/java/net/sf/jabref/model/database/BibDatabase.java @@ -530,7 +530,12 @@ public void registerListener(Object listener) { * @param listener listener (subscriber) to remove */ public void unregisterListener(Object listener) { - this.eventBus.unregister(listener); + try { + this.eventBus.unregister(listener); + } catch (IllegalArgumentException e) { + // occurs if the event source has not been registered, should not prevent shutdown + LOGGER.debug(e); + } } @Subscribe diff --git a/src/main/java/net/sf/jabref/model/entry/BibEntry.java b/src/main/java/net/sf/jabref/model/entry/BibEntry.java index f1e55b73751..7656456ff28 100644 --- a/src/main/java/net/sf/jabref/model/entry/BibEntry.java +++ b/src/main/java/net/sf/jabref/model/entry/BibEntry.java @@ -764,7 +764,12 @@ public void registerListener(Object object) { } public void unregisterListener(Object object) { - this.eventBus.unregister(object); + try { + this.eventBus.unregister(object); + } catch (IllegalArgumentException e) { + // occurs if the event source has not been registered, should not prevent shutdown + LOGGER.debug(e); + } } public BibEntry withField(String field, String value) { diff --git a/src/main/java/net/sf/jabref/model/metadata/MetaData.java b/src/main/java/net/sf/jabref/model/metadata/MetaData.java index c55e3d52718..c9be65a839f 100644 --- a/src/main/java/net/sf/jabref/model/metadata/MetaData.java +++ b/src/main/java/net/sf/jabref/model/metadata/MetaData.java @@ -254,7 +254,11 @@ public void registerListener(Object listener) { } public void unregisterListener(Object listener) { - this.eventBus.unregister(listener); + try { + this.eventBus.unregister(listener); + } catch (IllegalArgumentException e) { + // occurs if the event source has not been registered, should not prevent shutdown + } } private Optional getDefaultCiteKeyPattern() {