Changeset 13420 in josm


Ignore:
Timestamp:
2018-02-12T23:19:49+01:00 (11 days ago)
Author:
bastiK
Message:

fixed #11607 - RangeViolatedError: the new range must be within a single subrange

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/PurgeCommand.java

    r13173 r13420  
    115115                }
    116116            }
     117            getAffectedDataSet().clearMappaintCache();
    117118        } finally {
    118119            getAffectedDataSet().endUpdate();
     
    126127            return;
    127128
    128         for (OsmPrimitive osm : toPurge) {
    129             PrimitiveData data = makeIncompleteDataByPrimId.get(osm);
    130             if (data != null) {
    131                 if (getAffectedDataSet().getPrimitiveById(osm) != osm)
    132                     throw new AssertionError(
    133                             String.format("Primitive %s has been made incomplete when purging, but it cannot be found on undo.", osm));
    134                 osm.load(data);
    135             } else {
    136                 if (getAffectedDataSet().getPrimitiveById(osm) != null)
    137                     throw new AssertionError(String.format("Primitive %s was removed when purging, but is still there on undo", osm));
    138                 getAffectedDataSet().addPrimitive(osm);
    139             }
    140         }
    141 
    142         for (Conflict<?> conflict : purgedConflicts) {
    143             getAffectedDataSet().getConflicts().add(conflict);
     129        getAffectedDataSet().beginUpdate();
     130        try {
     131            for (OsmPrimitive osm : toPurge) {
     132                PrimitiveData data = makeIncompleteDataByPrimId.get(osm);
     133                if (data != null) {
     134                    if (getAffectedDataSet().getPrimitiveById(osm) != osm)
     135                        throw new AssertionError(
     136                                String.format("Primitive %s has been made incomplete when purging, but it cannot be found on undo.", osm));
     137                    osm.load(data);
     138                } else {
     139                    if (getAffectedDataSet().getPrimitiveById(osm) != null)
     140                        throw new AssertionError(String.format("Primitive %s was removed when purging, but is still there on undo", osm));
     141                    getAffectedDataSet().addPrimitive(osm);
     142                }
     143            }
     144
     145            for (Conflict<?> conflict : purgedConflicts) {
     146                getAffectedDataSet().getConflicts().add(conflict);
     147            }
     148            getAffectedDataSet().clearMappaintCache();
     149        } finally {
     150            getAffectedDataSet().endUpdate();
    144151        }
    145152    }
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r13309 r13420  
    200200    private final ConflictCollection conflicts = new ConflictCollection();
    201201
     202    private short mappaintCacheIdx = 1;
     203
    202204    /**
    203205     * Constructs a new {@code DataSet}.
     
    13801382        return null;
    13811383    }
     1384
     1385    /**
     1386     * Returns mappaint cache index for this DataSet.
     1387     *
     1388     * If the {@link OsmPrimitive#mappaintCacheIdx} is not equal to the DataSet mappaint
     1389     * cache index, this means the cache for that primitive is out of date.
     1390     * @return mappaint cache index
     1391     * @since 13420
     1392     */
     1393    public short getMappaintCacheIndex() {
     1394        return mappaintCacheIdx;
     1395    }
     1396
     1397    /**
     1398     * Clear the mappaint cache for this DataSet.
     1399     * @since 13420
     1400     */
     1401    public void clearMappaintCache() {
     1402        mappaintCacheIdx++;
     1403    }
    13821404}
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r13309 r13420  
    204204
    205205    /**
     206     * Check if the cached style for this primitive is up to date.
     207     * @return true if the cached style for this primitive is up to date
     208     * @since 13420
     209     */
     210    public final boolean isCachedStyleUpToDate() {
     211        return mappaintStyle != null && mappaintCacheIdx == dataSet.getMappaintCacheIndex();
     212    }
     213
     214    /**
     215     * Declare that the cached style for this primitive is up to date.
     216     * @since 13420
     217     */
     218    public final void declareCachedStyleUpToDate() {
     219        this.mappaintCacheIdx = dataSet.getMappaintCacheIndex();
     220    }
     221
     222    /**
    206223     * Returns mappaint cache index.
    207224     * @return mappaint cache index
    208      */
     225     * @deprecated no longer supported (see also {@link #isCachedStyleUpToDate()})
     226     */
     227    @Deprecated
    209228    public final short getMappaintCacheIdx() {
    210229        return mappaintCacheIdx;
     
    214233     * Sets the mappaint cache index.
    215234     * @param mappaintCacheIdx mappaint cache index
    216      */
     235     * @deprecated no longer supported (see also {@link #declareCachedStyleUpToDate()})
     236     */
     237    @Deprecated
    217238    public final void setMappaintCacheIdx(short mappaintCacheIdx) {
    218239        this.mappaintCacheIdx = mappaintCacheIdx;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java

    r13104 r13420  
    1919import org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon;
    2020import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache;
     21import org.openstreetmap.josm.gui.MainApplication;
    2122import org.openstreetmap.josm.gui.NavigatableComponent;
     23import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2224import org.openstreetmap.josm.gui.mappaint.DividedScale.RangeViolatedError;
    2325import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
     
    9092            preferenceCache.clear();
    9193            backgroundColorCache = null;
     94            MainApplication.getLayerManager().getLayersOfType(OsmDataLayer.class).forEach(
     95                    dl -> dl.data.clearMappaintCache());
    9296        });
    9397    }
     
    139143     */
    140144    public Pair<StyleElementList, Range> getStyleCacheWithRange(OsmPrimitive osm, double scale, NavigatableComponent nc) {
    141         if (osm.mappaintStyle == null || osm.getMappaintCacheIdx() != cacheIdx || scale <= 0) {
     145        if (!osm.isCachedStyleUpToDate() || scale <= 0) {
    142146            osm.mappaintStyle = StyleCache.EMPTY_STYLECACHE;
    143147        } else {
     
    195199                    + ", scale: " + scale + ", new stylelist: " + p.a + ", new range: " + p.b + ')', e);
    196200        }
    197         osm.setMappaintCacheIdx(cacheIdx);
     201        osm.declareCachedStyleUpToDate();
    198202        return p;
    199203    }
Note: See TracChangeset for help on using the changeset viewer.