Fix an issue where SwingUtilities.invokeAndWait is called in the EDT

Signed-off-by: Taylor Smock <taylor.smock@kaart.com>
pull/1/head
Taylor Smock 2020-02-03 10:11:39 -07:00
rodzic cbde7fb181
commit e1bd79ca9c
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 625F6A74A3E4311A
1 zmienionych plików z 26 dodań i 20 usunięć

Wyświetl plik

@ -128,29 +128,35 @@ public class GetDataRunnable extends RecursiveTask<DataSet> {
* @param bounds
*/
public static void cleanup(DataSet dataSet, Bounds bounds) {
try {
SwingUtilities.invokeAndWait(() -> {
synchronized (LOCK) {
removeRedundantSource(dataSet);
replaceTags(dataSet);
removeCommonTags(dataSet);
mergeNodes(dataSet);
cleanupDataSet(dataSet);
mergeWays(dataSet);
removeAlreadyAddedData(dataSet);
new MergeDuplicateWays(dataSet).executeCommand();
(bounds == null ? dataSet.getWays() : dataSet.searchWays(bounds.toBBox())).parallelStream()
.filter(way -> !way.isDeleted()).forEach(GetDataRunnable::cleanupArtifacts);
}
});
} catch (InterruptedException e) {
Logging.debug(e);
Thread.currentThread().interrupt();
} catch (InvocationTargetException e) {
Logging.debug(e);
if (SwingUtilities.isEventDispatchThread()) {
realCleanup(dataSet, bounds);
} else {
try {
SwingUtilities.invokeAndWait(() -> {
realCleanup(dataSet, bounds);
});
} catch (InterruptedException e) {
Logging.debug(e);
Thread.currentThread().interrupt();
} catch (InvocationTargetException e) {
Logging.debug(e);
}
}
}
private static synchronized void realCleanup(DataSet dataSet, Bounds bounds) {
removeRedundantSource(dataSet);
replaceTags(dataSet);
removeCommonTags(dataSet);
mergeNodes(dataSet);
cleanupDataSet(dataSet);
mergeWays(dataSet);
removeAlreadyAddedData(dataSet);
new MergeDuplicateWays(dataSet).executeCommand();
(bounds == null ? dataSet.getWays() : dataSet.searchWays(bounds.toBBox())).parallelStream()
.filter(way -> !way.isDeleted()).forEach(GetDataRunnable::cleanupArtifacts);
}
/**
* Remove redudant sources from objects (if source on way and source on node,
* and node doesn't have any other tags, then node doesn't need the source)