Skip to content

Commit

Permalink
Fix Autosave threading issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Ka0o0 committed Feb 20, 2020
1 parent 505fc74 commit fbc1357
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an issue where an entry containing an external filename with curly braces could not be saved. Curly braces are now longer allowed in filenames. [#5899](https://github.com/JabRef/jabref/issues/5899)
- We fixed an issue where changing the type of an entry did not update the main table. [#5906](https://github.com/JabRef/jabref/issues/5906)
- We fixed an issue where opening a library from the recent libraries menu was not possible. [#5939](https://github.com/JabRef/jabref/issues/5939)
- We fixed an issue where Autosave actions could lead to an exception. [#5658](https://github.com/JabRef/jabref/issues/5658)

### Removed

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/jabref/gui/dialogs/AutosaveUIManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.jabref.Globals;
import org.jabref.gui.BasePanel;
import org.jabref.gui.exporter.SaveDatabaseAction;
import org.jabref.gui.util.DefaultTaskExecutor;
import org.jabref.model.database.event.AutosaveEvent;

import com.google.common.eventbus.Subscribe;
Expand All @@ -26,7 +27,9 @@ public AutosaveUIManager(BasePanel panel) {
@Subscribe
public void listen(@SuppressWarnings("unused") AutosaveEvent event) {
try {
new SaveDatabaseAction(panel, Globals.prefs, Globals.entryTypesManager).save(SaveDatabaseAction.SaveDatabaseMode.SILENT);
DefaultTaskExecutor.runAndWaitInJavaFXThread(() -> {
new SaveDatabaseAction(panel, Globals.prefs, Globals.entryTypesManager).save(SaveDatabaseAction.SaveDatabaseMode.SILENT);
});
} catch (Throwable e) {
LOGGER.error("Problem occurred while saving.", e);
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
* <p>
* The save operation is loaded off of the GUI thread using {@link BackgroundTask}. Callers can query whether the
* operation was canceled, or whether it was successful.
* However, the callee must make sure that methods are called from the JavaFX application thread as {@link BasePanel}
* and {@link JabRefFrame} are manipulated during saving operations.
*/
public class SaveDatabaseAction {

Expand Down

0 comments on commit fbc1357

Please sign in to comment.