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

Try to fix not on FX thread for search and autocomplete #4618

Merged
merged 2 commits into from
Jan 27, 2019
Merged
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
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