Changeset 13213 in josm


Ignore:
Timestamp:
2017-12-17T20:36:48+01:00 (7 years ago)
Author:
Don-vip
Message:

fix #15653, see #8509 - IllegalStateException during Upload (regression from r13133 - patch by udit, minor changes)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/MainLayerManager.java

    r13152 r13213  
    1414import org.openstreetmap.josm.data.osm.DataSet;
    1515import org.openstreetmap.josm.gui.MainApplication;
     16import org.openstreetmap.josm.gui.io.AsynchronousUploadPrimitivesTask;
    1617import org.openstreetmap.josm.gui.util.GuiHelper;
    1718
     
    274275    @Override
    275276    protected Collection<Layer> realRemoveSingleLayer(Layer layer) {
     277        if ((layer instanceof OsmDataLayer) && (((OsmDataLayer) layer).isReadOnly())) {
     278            GuiHelper.runInEDT(() -> JOptionPane.showMessageDialog(MainApplication.parent,
     279                    tr("Trying to delete the layer with background upload. Please wait until the upload is finished.")));
     280
     281            // Return an empty collection for allowing to delete other layers
     282            return new ArrayList<>();
     283        }
     284
    276285        if (layer == activeLayer || layer == editLayer) {
    277286            Layer nextActive = suggestNextActiveLayer(layer);
     
    409418    @Override
    410419    protected synchronized void realResetState() {
    411         // active and edit layer are unset automatically
    412         super.realResetState();
    413 
    414         activeLayerChangeListeners.clear();
    415         layerAvailabilityListeners.clear();
     420        // Reset state if no asynchronous upload is under progress
     421        if (!AsynchronousUploadPrimitivesTask.getCurrentAsynchronousUploadTask().isPresent()) {
     422            // active and edit layer are unset automatically
     423            super.realResetState();
     424
     425            activeLayerChangeListeners.clear();
     426            layerAvailabilityListeners.clear();
     427        } else {
     428            GuiHelper.runInEDT(() -> JOptionPane.showMessageDialog(MainApplication.parent,
     429                    tr("A background upload is already in progress. Cannot reset state until the upload is finished.")));
     430        }
    416431    }
    417432
Note: See TracChangeset for help on using the changeset viewer.