Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure that unregistered event sources do not stop JabRef from shu… #2487

Merged
merged 4 commits into from
Jan 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/net/sf/jabref/model/database/BibDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/net/sf/jabref/model/entry/BibEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/net/sf/jabref/model/metadata/MetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> getDefaultCiteKeyPattern() {
Expand Down