Changeset 10400 in josm


Ignore:
Timestamp:
2016-06-16T15:49:07+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #12974 - Unit tests hang (patch by michael2402) - gsoc-core

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/Main.java

    r10395 r10400  
    102102import org.openstreetmap.josm.gui.progress.ProgressMonitorExecutor;
    103103import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets;
     104import org.openstreetmap.josm.gui.util.GuiHelper;
    104105import org.openstreetmap.josm.gui.util.RedirectInputMap;
    105106import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
     
    809810     * the viewport isn't changed
    810811     */
    811     public final synchronized void addLayer(final Layer layer, ProjectionBounds bounds) {
     812    public final void addLayer(Layer layer, ProjectionBounds bounds) {
    812813        addLayer(layer, bounds == null ? null : new ViewportData(bounds));
    813814    }
     
    821822     * @param viewport the viewport to zoom to; can be null, then the viewport isn't changed
    822823     */
    823     public final synchronized void addLayer(final Layer layer, ViewportData viewport) {
     824    public final void addLayer(Layer layer, ViewportData viewport) {
    824825        getLayerManager().addLayer(layer);
    825826        if (viewport != null) {
     
    828829    }
    829830
     831    /**
     832     * Creates the map frame. Call only in EDT Thread.
     833     * @param firstLayer The first layer that was added.
     834     * @param viewportData The initial viewport. Can be <code>null</code> to be automatically computed.
     835     */
    830836    public synchronized void createMapFrame(Layer firstLayer, ViewportData viewportData) {
     837        GuiHelper.assertCallFromEdt();
    831838        MapFrame mapFrame = new MapFrame(contentPanePrivate, viewportData);
    832839        setMapFrame(mapFrame);
  • trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java

    r10396 r10400  
    1515import org.openstreetmap.josm.gui.layer.Layer;
    1616import org.openstreetmap.josm.gui.preferences.ToolbarPreferences;
     17import org.openstreetmap.josm.gui.util.GuiHelper;
    1718import org.openstreetmap.josm.io.CertificateAmendment;
    1819import org.openstreetmap.josm.io.OsmApi;
     
    115116
    116117        if (createGui) {
    117             if (Main.toolbar == null) {
    118                 Main.toolbar = new ToolbarPreferences();
    119             }
    120             if (Main.main == null) {
    121                 new MainApplication().initialize();
    122             }
    123             if (Main.map == null) {
    124                 Main.main.createMapFrame(null, null);
    125             } else {
    126                 for (Layer l: Main.getLayerManager().getLayers()) {
    127                     Main.getLayerManager().removeLayer(l);
     118            GuiHelper.runInEDTAndWaitWithException(new Runnable() {
     119                @Override
     120                public void run() {
     121                    setupGUI();
    128122                }
     123            });
     124        }
     125    }
     126
     127    private void setupGUI() {
     128        if (Main.toolbar == null) {
     129            Main.toolbar = new ToolbarPreferences();
     130        }
     131        if (Main.main == null) {
     132            new MainApplication().initialize();
     133        }
     134        if (Main.map == null) {
     135            Main.main.createMapFrame(null, null);
     136        } else {
     137            for (Layer l: Main.getLayerManager().getLayers()) {
     138                Main.getLayerManager().removeLayer(l);
    129139            }
    130140        }
Note: See TracChangeset for help on using the changeset viewer.