Changeset 11287 in josm


Ignore:
Timestamp:
2016-11-19T16:38:29+01:00 (3 years ago)
Author:
michael2402
Message:

Fix #14004: Check range of thread count and image size.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/WMSSettingsPanel.java

    r8526 r11287  
    1616import org.openstreetmap.josm.gui.layer.WMSLayer;
    1717import org.openstreetmap.josm.tools.GBC;
     18import org.openstreetmap.josm.tools.Utils;
    1819
    1920/**
     
    2223 */
    2324public class WMSSettingsPanel extends JPanel {
     25
     26    private static final int IMAGE_SIZE_MIN = 1;
     27    private static final int IMAGE_SIZE_MAX = 4096;
     28    private static final int THREADS_MIN = 1;
     29    private static final int THREADS_MAX = 30;
    2430
    2531    // WMS Settings
     
    4349        add(Box.createHorizontalGlue(), GBC.eol().fill(GBC.HORIZONTAL));
    4450        JLabel labelSimConn = new JLabel(tr("Simultaneous connections:"));
    45         spinSimConn = new JSpinner(new SpinnerNumberModel(WMSCachedTileLoaderJob.THREAD_LIMIT.get().intValue(), 1, 30, 1));
     51        int threadLimitValue = Utils.clamp(WMSCachedTileLoaderJob.THREAD_LIMIT.get(), THREADS_MIN, THREADS_MAX);
     52        spinSimConn = new JSpinner(new SpinnerNumberModel(threadLimitValue, THREADS_MIN, THREADS_MAX, 1));
    4653        labelSimConn.setLabelFor(spinSimConn);
    4754        add(labelSimConn, GBC.std());
     
    5158        // Tile size
    5259        JLabel labelTileSize = new JLabel(tr("Tile size:"));
    53         tileSize = new JSpinner(new SpinnerNumberModel(WMSLayer.PROP_IMAGE_SIZE.get().intValue(), 1, 4096, 128));
     60        int tileSizeValue = Utils.clamp(WMSLayer.PROP_IMAGE_SIZE.get(), IMAGE_SIZE_MIN, IMAGE_SIZE_MAX);
     61        tileSize = new JSpinner(new SpinnerNumberModel(tileSizeValue, IMAGE_SIZE_MIN, IMAGE_SIZE_MAX, 128));
    5462        labelTileSize.setLabelFor(tileSize);
    5563        add(labelTileSize, GBC.std());
Note: See TracChangeset for help on using the changeset viewer.