Changeset 4814 in josm for trunk


Ignore:
Timestamp:
2012-01-17T22:59:35+01:00 (8 years ago)
Author:
bastiK
Message:

fixed #7193 - Opening more than two gpx-Tracks fails (regression)

File:
1 edited

Legend:

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

    r4800 r4814  
    2222public class OsmImporter extends FileImporter {
    2323
    24     protected OsmDataLayer layer;
    25     protected Runnable postLayerTask;
     24    protected class OsmImporterData {
     25        public OsmDataLayer layer;
     26        public Runnable postLayerTask;
     27    }
    2628
    2729    public OsmImporter() {
     
    4547
    4648    protected void importData(InputStream in, final File associatedFile) throws IllegalDataException {
    47         loadLayer(in, associatedFile, associatedFile == null ? OsmDataLayer.createNewName() : associatedFile.getName(), NullProgressMonitor.INSTANCE);
    48 
    49         final OsmDataLayer layer = this.layer;
    50         final Runnable postLayerTask = this.postLayerTask;
     49        final OsmImporterData data = loadLayer(in, associatedFile,
     50                associatedFile == null ? OsmDataLayer.createNewName() : associatedFile.getName(), NullProgressMonitor.INSTANCE);
    5151
    5252        // FIXME: remove UI stuff from IO subsystem
     
    5454            @Override
    5555            public void run() {
    56                 Main.main.addLayer(layer);
    57                 postLayerTask.run();
    58                 layer.onPostLoadFromFile();
     56                Main.main.addLayer(data.layer);
     57                data.postLayerTask.run();
     58                data.layer.onPostLoadFromFile();
    5959            }
    6060        });
     
    6565     * associatedFile can be null if the stream does not come from a file.
    6666     */
    67     public void loadLayer(InputStream in, final File associatedFile, final String layerName, ProgressMonitor progressMonitor) throws IllegalDataException {
     67    public OsmImporterData loadLayer(InputStream in, final File associatedFile, final String layerName, ProgressMonitor progressMonitor) throws IllegalDataException {
    6868        final DataSet dataSet = parseDataSet(in, progressMonitor);
    6969        if (dataSet == null) {
    7070            throw new IllegalDataException(tr("Invalid dataset"));
    7171        }
    72         layer = createLayer(dataSet, associatedFile, layerName);
    73         postLayerTask = createPostLayerTask(dataSet, associatedFile, layerName);
     72        OsmImporterData data = new OsmImporterData();
     73        data.layer = createLayer(dataSet, associatedFile, layerName);
     74        data.postLayerTask = createPostLayerTask(dataSet, associatedFile, layerName, data.layer);
     75        return data;
    7476    }
    7577   
     
    8284    }
    8385   
    84     protected Runnable createPostLayerTask(final DataSet dataSet, final File associatedFile, final String layerName) {
     86    protected Runnable createPostLayerTask(final DataSet dataSet, final File associatedFile, final String layerName, final OsmDataLayer layer) {
    8587        return new Runnable() {
    8688            @Override
     
    103105        };
    104106    }
    105 
    106     public OsmDataLayer getLayer() {
    107         return layer;
    108     }
    109 
    110     public Runnable getPostLayerTask() {
    111         return postLayerTask;
    112     }
    113107}
Note: See TracChangeset for help on using the changeset viewer.