Ignore:
Timestamp:
2015-04-07T22:17:42+02:00 (9 years ago)
Author:
stoecker
Message:

fix #11317 - tile flickering during TMS loading - patch by wiktorn

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java

    r8174 r8176  
    2727import org.apache.commons.jcs.engine.behavior.ICacheElement;
    2828import org.openstreetmap.gui.jmapviewer.FeatureAdapter;
     29import org.openstreetmap.josm.data.cache.ICachedLoaderListener.LoadResult;
    2930import org.openstreetmap.josm.data.preferences.IntegerProperty;
    3031
     
    152153                // we got something in cache, and it's valid, so lets return it
    153154                log.log(Level.FINE, "JCS - Returning object from cache: {0}", getCacheKey());
    154                 finishLoading(true);
     155                finishLoading(LoadResult.SUCCESS);
    155156                return;
    156157            }
     
    162163                // queue was full, try again later
    163164                log.log(Level.FINE, "JCS - rejected job for: {0}", getCacheKey());
    164                 finishLoading(false);
     165                finishLoading(LoadResult.REJECTED);
    165166            }
    166167        }
     
    206207            // try to load object from remote resource
    207208            if (loadObject()) {
    208                 finishLoading(true);
     209                finishLoading(LoadResult.SUCCESS);
    209210            } else {
    210211                // if loading failed - check if we can return stale entry
    211212                if (isObjectLoadable()) {
    212213                    // try to get stale entry in cache
    213                     finishLoading(true);
     214                    finishLoading(LoadResult.SUCCESS);
    214215                    log.log(Level.FINE, "JCS - found stale object in cache: {0}", getUrl());
    215216                } else {
    216217                    // failed completely
    217                     finishLoading(false);
     218                    finishLoading(LoadResult.FAILURE);
    218219                }
    219220            }
     
    224225
    225226
    226     private void finishLoading(boolean success) {
     227    private void finishLoading(LoadResult result) {
    227228        Set<ICachedLoaderListener> listeners = null;
    228229        synchronized (inProgress) {
     
    235236        try {
    236237            for (ICachedLoaderListener l: listeners) {
    237                 l.loadingFinished(cacheData, success);
     238                l.loadingFinished(cacheData, result);
    238239            }
    239240        } catch (Exception e) {
     
    241242            log.log(Level.FINE, "Stacktrace", e);
    242243            for (ICachedLoaderListener l: listeners) {
    243                 l.loadingFinished(cacheData, false);
     244                l.loadingFinished(cacheData, LoadResult.FAILURE);
    244245            }
    245246
Note: See TracChangeset for help on using the changeset viewer.