Ticket #2917: select-existing-edit-layer.patch

File select-existing-edit-layer.patch, 1.3 KB (added by plaicy, 16 years ago)
  • src/org/openstreetmap/josm/Main.java

     
    227227    }
    228228    /**
    229229     * Replies the current edit layer. Creates one if no {@see OsmDataLayer}
    230      * exists. Replies null, if the currently active layer isn't an instance
    231      * of {@see OsmDataLayer}.
     230     * exists.
    232231     *
    233232     * @return the current edit layer
    234233     */
    235234    public final OsmDataLayer createOrGetEditLayer() {
    236         if (map == null || map.mapView.getEditLayer() == null) {
     235        OsmDataLayer osmDataLayer = null;
     236        if ((map != null) &&
     237            ((osmDataLayer = map.mapView.getEditLayer()) == null)) {
     238            for (Layer layer : Main.map.mapView.getAllLayers()) {
     239                if (layer instanceof OsmDataLayer) {
     240                    osmDataLayer = (OsmDataLayer) layer;
     241                    break;
     242                }
     243            }
     244        }
     245        if (osmDataLayer == null) {
    237246            menu.newAction.actionPerformed(null);
     247            osmDataLayer = map.mapView.getEditLayer();
    238248        }
    239         return map.mapView.getEditLayer();
     249
     250        return osmDataLayer;
    240251    }
    241252
    242253    /**