Changeset 9509 in josm for trunk/src/org


Ignore:
Timestamp:
2016-01-17T19:46:20+01:00 (9 years ago)
Author:
simon04
Message:

fix #9925 - Allow to stop downloading GPS data and keep the downloaded part

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java

    r9067 r9509  
    129129        protected void finish() {
    130130            rememberDownloadedData(rawData);
    131             if (isCanceled() || isFailed())
    132                 return;
    133131            if (rawData == null)
    134132                return;
  • trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java

    r8995 r9509  
    66import java.io.IOException;
    77import java.io.InputStream;
     8import java.net.SocketException;
    89import java.util.List;
    910
     11import org.openstreetmap.josm.Main;
    1012import org.openstreetmap.josm.data.Bounds;
    1113import org.openstreetmap.josm.data.DataSource;
     
    4951        GpxData result = null;
    5052        String url = "trackpoints?bbox="+b.getMinLon()+','+b.getMinLat()+','+b.getMaxLon()+','+b.getMaxLat()+"&page=";
    51         for (int i = 0; !done; ++i) {
     53        for (int i = 0; !done && !isCanceled(); ++i) {
    5254            progressMonitor.subTask(tr("Downloading points {0} to {1}...", i * 5000, (i + 1) * 5000));
    5355            try (InputStream in = getInputStream(url+i, progressMonitor.createSubTaskMonitor(1, true))) {
     
    6567                } else {
    6668                    done = true;
     69                }
     70            } catch (OsmTransferException | SocketException ex) {
     71                if (isCanceled()) {
     72                    final OsmTransferCanceledException canceledException = new OsmTransferCanceledException("Operation canceled");
     73                    canceledException.initCause(ex);
     74                    Main.warn(canceledException);
    6775                }
    6876            }
     
    209217            }
    210218            return notes;
    211         } catch (IOException e) {
    212             throw new OsmTransferException(e);
    213         } catch (SAXException e) {
     219        } catch (IOException | SAXException e) {
    214220            throw new OsmTransferException(e);
    215221        } finally {
Note: See TracChangeset for help on using the changeset viewer.