Changeset 11188 in josm for trunk/src/org


Ignore:
Timestamp:
2016-10-30T00:11:11+02:00 (8 years ago)
Author:
wiktorn
Message:

Allow working on readonly JOSM Home

Return null CachedTileLoaderFactory when cache creation fails.
Adapt SlippyMapBBoxChooser so it uses un-cached loader when cached is unavailable.

Closes: #13786

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/CachedTileLoaderFactory.java

    r10651 r11188  
    1414import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry;
    1515import org.openstreetmap.josm.data.preferences.StringProperty;
     16import org.openstreetmap.josm.tools.CheckParameterUtil;
    1617
    1718/**
     
    3536     */
    3637    public CachedTileLoaderFactory(ICacheAccess<String, BufferedImageCacheEntry> cache, Class<? extends TileLoader> tileLoaderClass) {
     38        CheckParameterUtil.ensureParameterNotNull(cache, "cache");
    3739        this.cache = cache;
    3840        try {
  • trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java

    r10755 r11188  
    3939import org.openstreetmap.josm.data.imagery.ImageryLayerInfo;
    4040import org.openstreetmap.josm.data.imagery.TMSCachedTileLoader;
     41import org.openstreetmap.josm.data.imagery.TileLoaderFactory;
    4142import org.openstreetmap.josm.data.preferences.StringProperty;
    4243import org.openstreetmap.josm.gui.layer.AbstractCachedTileSourceLayer;
     
    128129        headers.put("User-Agent", Version.getInstance().getFullAgentString());
    129130
    130         cachedLoader = AbstractCachedTileSourceLayer.getTileLoaderFactory("TMS", TMSCachedTileLoader.class).makeTileLoader(this, headers);
     131        TileLoaderFactory cachedLoaderFactory = AbstractCachedTileSourceLayer.getTileLoaderFactory("TMS", TMSCachedTileLoader.class);
     132        if (cachedLoaderFactory != null) {
     133            cachedLoader = cachedLoaderFactory.makeTileLoader(this, headers);
     134        } else {
     135            cachedLoader = null;
     136        }
    131137
    132138        uncachedLoader = new OsmTileLoader(this);
     
    206212
    207213    public final void setFileCacheEnabled(boolean enabled) {
    208         if (enabled) {
     214        if (enabled && cachedLoader != null) {
    209215            setTileLoader(cachedLoader);
    210216        } else {
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractCachedTileSourceLayer.java

    r9860 r11188  
    113113     */
    114114    public static TileLoaderFactory getTileLoaderFactory(String name, Class<? extends TileLoader> klazz) {
    115         return new CachedTileLoaderFactory(getCache(name), klazz);
     115        CacheAccess<String, BufferedImageCacheEntry> cache = getCache(name);
     116        if (cache == null) {
     117            return null;
     118        }
     119        return new CachedTileLoaderFactory(cache, klazz);
    116120    }
    117121
Note: See TracChangeset for help on using the changeset viewer.