Index: /trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java	(revision 1902)
+++ /trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java	(revision 1903)
@@ -73,4 +73,12 @@
     }
 
+    protected Layer getActiveLayer() {
+        try {
+            return Main.map.mapView.getActiveLayer();
+        } catch(NullPointerException e) {
+            return null;
+        }
+    }
+
     private BoundingXYVisitor getBoundingBox() {
         BoundingXYVisitor v = new BoundingXYVisitor();
@@ -80,5 +88,7 @@
             }
         } else if (mode.equals("layer")) {
-            Main.map.mapView.getActiveLayer().visitBoundingBox(v);
+            if (getActiveLayer() == null)
+                return null;
+            getActiveLayer().visitBoundingBox(v);
         } else if (mode.equals("selection") || mode.equals("conflict")) {
             Collection<OsmPrimitive> sel = new HashSet<OsmPrimitive>();
@@ -131,4 +141,6 @@
         if ("selection".equals(mode)) {
             setEnabled(getCurrentDataSet() != null && ! getCurrentDataSet().getSelected().isEmpty());
+        }  else if ("layer".equals(mode)) {
+            setEnabled(getActiveLayer() != null);
         } else {
             setEnabled(
