Changeset 11261 in josm for trunk/src


Ignore:
Timestamp:
2016-11-16T13:04:17+01:00 (3 years ago)
Author:
simon04
Message:

fix #13985 - Freezes when creating a layer named "Data Layer "

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r11177 r11261  
    357357        data.addDataSetListener(MultipolygonCache.getInstance());
    358358        DataSet.addSelectionListener(this);
    359         if (name != null && name.startsWith(createLayerName(""))) {
     359        if (name != null && name.startsWith(createLayerName(""))
     360                && Character.isDigit((name.substring(createLayerName("").length()) + "XX" /*avoid StringIndexOutOfBoundsException*/).charAt(1))) {
    360361            while (AlphanumComparator.getInstance().compare(createLayerName(dataLayerCounter), name) < 0) {
    361                 dataLayerCounter.incrementAndGet();
     362                final int i = dataLayerCounter.incrementAndGet();
     363                if (i > 1_000_000) {
     364                    break; // to avoid looping in unforeseen case
     365                }
    362366            }
    363367        }
Note: See TracChangeset for help on using the changeset viewer.