kopia lustrzana https://github.com/JOSM/MapWithAI
FIXUP: Avoid a potential deadlock on the EDT
Signed-off-by: Taylor Smock <taylor.smock@kaart.com>pull/1/head
rodzic
106313bc49
commit
267c97200f
|
@ -19,6 +19,8 @@ import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import org.openstreetmap.josm.data.StructUtils;
|
import org.openstreetmap.josm.data.StructUtils;
|
||||||
import org.openstreetmap.josm.data.imagery.ImageryInfo;
|
import org.openstreetmap.josm.data.imagery.ImageryInfo;
|
||||||
import org.openstreetmap.josm.data.preferences.BooleanProperty;
|
import org.openstreetmap.josm.data.preferences.BooleanProperty;
|
||||||
|
@ -71,12 +73,15 @@ public class MapWithAILayerInfo {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
AtomicBoolean finished = new AtomicBoolean();
|
AtomicBoolean finished = new AtomicBoolean();
|
||||||
instance = new MapWithAILayerInfo(() -> finished.set(true));
|
instance = new MapWithAILayerInfo(() -> finished.set(true));
|
||||||
while (!finished.get()) {
|
// Avoid a deadlock in the EDT.
|
||||||
try {
|
if (!SwingUtilities.isEventDispatchThread()) {
|
||||||
Thread.sleep(100);
|
while (!finished.get()) {
|
||||||
} catch (InterruptedException e) {
|
try {
|
||||||
Logging.error(e);
|
Thread.sleep(100);
|
||||||
Thread.currentThread().interrupt();
|
} catch (InterruptedException e) {
|
||||||
|
Logging.error(e);
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue