Skip to content

Commit

Permalink
Fix threading cleanup in performSearch
Browse files Browse the repository at this point in the history
Fixes #7606
  • Loading branch information
Siedlerchr committed Apr 28, 2021
1 parent d320975 commit 65e4647
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.File;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import javax.swing.undo.UndoManager;

Expand All @@ -23,9 +24,11 @@
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.database.DatabaseMerger;
import org.jabref.logic.database.DuplicateCheck;
import org.jabref.logic.importer.ImportCleanup;
import org.jabref.logic.importer.ParserResult;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.database.BibDatabaseMode;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibEntryTypesManager;
import org.jabref.model.entry.LinkedFile;
Expand All @@ -52,6 +55,7 @@ public class ImportEntriesViewModel extends AbstractViewModel {
private final PreferencesService preferences;
private final BibEntryTypesManager entryTypesManager;

private final ImportCleanup cleanup = new ImportCleanup(BibDatabaseMode.BIBTEX);
/**
* @param databaseContext the database to import into
* @param task the task executed for parsing the selected files(s).
Expand All @@ -78,10 +82,13 @@ public ImportEntriesViewModel(BackgroundTask<ParserResult> task,
this.message.bind(task.messageProperty());

task.onSuccess(parserResult -> {

// store the complete parser result (to import groups, ... later on)
this.parserResult = parserResult;

List<BibEntry> entries = parserResult.getDatabase().getEntries().stream().map(cleanup::doPostCleanup).collect(Collectors.toList());
// fill in the list for the user, where one can select the entries to import
entries.addAll(parserResult.getDatabase().getEntries());
entries.addAll(entries);
}).onFailure(ex -> {
LOGGER.error("Error importing", ex);
dialogService.showErrorDialogAndWait(ex);
Expand Down

0 comments on commit 65e4647

Please sign in to comment.