Changeset 1903 in josm for trunk/src/org


Ignore:
Timestamp:
2009-08-04T08:08:30+02:00 (15 years ago)
Author:
Gubaer
Message:

fixed #3180: Zoom to layer + GPX = NPE

File:
1 edited

Legend:

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

    r1895 r1903  
    7373    }
    7474
     75    protected Layer getActiveLayer() {
     76        try {
     77            return Main.map.mapView.getActiveLayer();
     78        } catch(NullPointerException e) {
     79            return null;
     80        }
     81    }
     82
    7583    private BoundingXYVisitor getBoundingBox() {
    7684        BoundingXYVisitor v = new BoundingXYVisitor();
     
    8088            }
    8189        } else if (mode.equals("layer")) {
    82             Main.map.mapView.getActiveLayer().visitBoundingBox(v);
     90            if (getActiveLayer() == null)
     91                return null;
     92            getActiveLayer().visitBoundingBox(v);
    8393        } else if (mode.equals("selection") || mode.equals("conflict")) {
    8494            Collection<OsmPrimitive> sel = new HashSet<OsmPrimitive>();
     
    131141        if ("selection".equals(mode)) {
    132142            setEnabled(getCurrentDataSet() != null && ! getCurrentDataSet().getSelected().isEmpty());
     143        }  else if ("layer".equals(mode)) {
     144            setEnabled(getActiveLayer() != null);
    133145        } else {
    134146            setEnabled(
Note: See TracChangeset for help on using the changeset viewer.