Only run layer creation in synchronized block.

Add layer outside of synchronized block (prevents deadlock)

Signed-off-by: Taylor Smock <taylor.smock@kaart.com>
pull/1/head v1.0.3
Taylor Smock 2020-01-13 08:33:01 -07:00
rodzic b6ca8bac33
commit 17959a4020
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 625F6A74A3E4311A
1 zmienionych plików z 1 dodań i 9 usunięć

Wyświetl plik

@ -4,7 +4,6 @@ package org.openstreetmap.josm.plugins.mapwithai.backend;
import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
import static org.openstreetmap.josm.tools.I18n.tr;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -278,16 +277,9 @@ public final class MapWithAIDataUtils {
}
final MapWithAILayer tLayer = layer;
if (SwingUtilities.isEventDispatchThread() && create) {
if (create && !MainApplication.getLayerManager().containsLayer(tLayer)) {
MainApplication.getLayerManager().addLayer(tLayer);
} else if (create) {
try {
SwingUtilities.invokeAndWait(() -> MainApplication.getLayerManager().addLayer(tLayer));
} catch (InvocationTargetException | InterruptedException e) {
Logging.error(e);
}
}
return layer;
}