From 69661a4a7ca4dc7f33726da3b80e2bfdcd1e0932 Mon Sep 17 00:00:00 2001 From: Christoph Date: Sun, 27 Jan 2019 12:04:48 +0100 Subject: [PATCH] Try to fix not on FX thread for search and autocomplete (#4618) * Try to fix not on FX thread for search and autocomplete * fix comment text --- src/main/java/org/jabref/gui/BasePanel.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/jabref/gui/BasePanel.java b/src/main/java/org/jabref/gui/BasePanel.java index a2e7e5734b6..777c06eaf6f 100644 --- a/src/main/java/org/jabref/gui/BasePanel.java +++ b/src/main/java/org/jabref/gui/BasePanel.java @@ -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()); } }