Index: src/org/openstreetmap/josm/gui/NavigatableComponent.java
===================================================================
--- src/org/openstreetmap/josm/gui/NavigatableComponent.java	(revision 15404)
+++ src/org/openstreetmap/josm/gui/NavigatableComponent.java	(working copy)
@@ -103,6 +103,8 @@
 
     /** Snap distance */
     public static final IntegerProperty PROP_SNAP_DISTANCE = new IntegerProperty("mappaint.node.snap-distance", 10);
+    /** Snap distance for way segments */
+    public static final IntegerProperty PROP_SEGMENT_SNAP_DISTANCE = new IntegerProperty("mappaint.segment.snap-distance", 10);
     /** Zoom steps to get double scale */
     public static final DoubleProperty PROP_ZOOM_RATIO = new DoubleProperty("zoom.ratio", 2.0);
     /** Divide intervals between native resolution levels to smaller steps if they are much larger than zoom ratio */
@@ -938,8 +940,12 @@
         DataSet ds = MainApplication.getLayerManager().getActiveDataSet();
 
         if (ds != null) {
-            double dist, snapDistanceSq = PROP_SNAP_DISTANCE.get();
-            snapDistanceSq *= snapDistanceSq;
+            int snapDistance = PROP_SNAP_DISTANCE.get();
+            double dist, snapDistanceSq;
+            if (snapDistance > getState().getViewHeight() || snapDistance > getState().getViewWidth()) {
+                Logging.error(PROP_SNAP_DISTANCE.getKey() + " used with zero height or width in view " + getState());
+            }
+            snapDistanceSq = (double) snapDistance * snapDistance;
 
             for (Node n : ds.searchNodes(getBBox(p, PROP_SNAP_DISTANCE.get()))) {
                 if (predicate.test(n)
@@ -1147,10 +1153,13 @@
         DataSet ds = MainApplication.getLayerManager().getActiveDataSet();
 
         if (ds != null) {
-            double snapDistanceSq = Config.getPref().getInt("mappaint.segment.snap-distance", 10);
-            snapDistanceSq *= snapDistanceSq;
+            int snapDistance = PROP_SEGMENT_SNAP_DISTANCE.get();
+            if (snapDistance >= getState().getViewHeight() || snapDistance >= getState().getViewWidth()) {
+                Logging.error(PROP_SEGMENT_SNAP_DISTANCE.getKey() + " used with zero height or width in view " + getState());
+            }
+            double snapDistanceSq = (double) snapDistance * snapDistance;
 
-            for (Way w : ds.searchWays(getBBox(p, Config.getPref().getInt("mappaint.segment.snap-distance", 10)))) {
+            for (Way w : ds.searchWays(getBBox(p, snapDistance))) {
                 if (!predicate.test(w)) {
                     continue;
                 }
