From 6f045e8a942782bbd856b903ca20e87065736b24 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Thu, 30 May 2019 18:15:47 +0200 Subject: [PATCH] Fix field formatter throwing exception on autosave Fixes #4958 --- .../autocompleter/AutoCompletionTextInputBinding.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/gui/autocompleter/AutoCompletionTextInputBinding.java b/src/main/java/org/jabref/gui/autocompleter/AutoCompletionTextInputBinding.java index 8bd97ec3b02..30ae74eff49 100644 --- a/src/main/java/org/jabref/gui/autocompleter/AutoCompletionTextInputBinding.java +++ b/src/main/java/org/jabref/gui/autocompleter/AutoCompletionTextInputBinding.java @@ -33,6 +33,8 @@ import javafx.util.Callback; import javafx.util.StringConverter; +import org.jabref.gui.util.DefaultTaskExecutor; + import org.controlsfx.control.textfield.AutoCompletionBinding; /** @@ -51,7 +53,7 @@ public class AutoCompletionTextInputBinding extends AutoCompletionBinding private AutoCompletionStrategy inputAnalyzer; private final ChangeListener textChangeListener = (obs, oldText, newText) -> { if (getCompletionTarget().isFocused()) { - setUserInputText(newText); + DefaultTaskExecutor.runInJavaFXThread(() -> setUserInputText(newText)); //we need to wrap this as it is called from a non fx thread in autosave } }; private boolean showOnFocus; @@ -73,9 +75,9 @@ private AutoCompletionTextInputBinding(final TextInputControl textInputControl, Callback> suggestionProvider) { this(textInputControl, - suggestionProvider, - AutoCompletionTextInputBinding.defaultStringConverter(), - new ReplaceStrategy()); + suggestionProvider, + AutoCompletionTextInputBinding.defaultStringConverter(), + new ReplaceStrategy()); } private AutoCompletionTextInputBinding(final TextInputControl textInputControl, @@ -99,6 +101,7 @@ private AutoCompletionTextInputBinding(final TextInputControl textInputControl, private static StringConverter defaultStringConverter() { return new StringConverter() { + @Override public String toString(T t) { return t == null ? null : t.toString();