Skip to content

Commit

Permalink
Try to fix not on FX thread for search and autocomplete (#4618)
Browse files Browse the repository at this point in the history
* Try to fix not on FX thread for search and autocomplete

* fix comment text
  • Loading branch information
Siedlerchr authored Jan 27, 2019
1 parent 16a68f3 commit 69661a4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -1345,39 +1345,41 @@ public void listen(EntryRemovedEvent entryRemovedEvent) {
/**
* Ensures that the search auto completer is up to date when entries are changed AKA Let the auto completer, if any,
* harvest words from the entry
* Actual methods for autocomplete indexing must run in javafx thread
*/
private class SearchAutoCompleteListener {

@Subscribe
public void listen(EntryAddedEvent addedEntryEvent) {
searchAutoCompleter.indexEntry(addedEntryEvent.getBibEntry());
DefaultTaskExecutor.runInJavaFXThread(() -> searchAutoCompleter.indexEntry(addedEntryEvent.getBibEntry()));
}

@Subscribe
public void listen(EntryChangedEvent entryChangedEvent) {
searchAutoCompleter.indexEntry(entryChangedEvent.getBibEntry());
DefaultTaskExecutor.runInJavaFXThread(() -> searchAutoCompleter.indexEntry(entryChangedEvent.getBibEntry()));
}
}

/**
* Ensures that the results of the current search are updated when a new entry is inserted into the database
* Actual methods for performing search must run in javafx thread
*/
private class SearchListener {

@Subscribe
public void listen(EntryAddedEvent addedEntryEvent) {
frame.getGlobalSearchBar().performSearch();
DefaultTaskExecutor.runInJavaFXThread(() -> frame.getGlobalSearchBar().performSearch());
}

@Subscribe
public void listen(EntryChangedEvent entryChangedEvent) {
frame.getGlobalSearchBar().performSearch();
DefaultTaskExecutor.runInJavaFXThread(() -> frame.getGlobalSearchBar().performSearch());
}

@Subscribe
public void listen(EntryRemovedEvent removedEntryEvent) {
// IMO only used to update the status (found X entries)
frame.getGlobalSearchBar().performSearch();
DefaultTaskExecutor.runInJavaFXThread(() -> frame.getGlobalSearchBar().performSearch());
}
}

Expand Down

0 comments on commit 69661a4

Please sign in to comment.