Changeset 13082 in josm for trunk


Ignore:
Timestamp:
2017-11-05T15:15:30+01:00 (6 years ago)
Author:
Don-vip
Message:

fix #15519 - add synchronization to MultipolygonCache

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/MultipolygonCache.java

    r12636 r13082  
    4343    private static final MultipolygonCache INSTANCE = new MultipolygonCache();
    4444
    45     private final Map<DataSet, Map<Relation, Multipolygon>> cache;
    46 
    47     private final Collection<PolyData> selectedPolyData;
     45    private final Map<DataSet, Map<Relation, Multipolygon>> cache = new ConcurrentHashMap<>(); // see ticket 11833
     46
     47    private final Collection<PolyData> selectedPolyData = new ArrayList<>();
    4848
    4949    private MultipolygonCache() {
    50         this.cache = new ConcurrentHashMap<>(); // see ticket 11833
    51         this.selectedPolyData = new ArrayList<>();
    5250        Main.addProjectionChangeListener(this);
    5351        DataSet.addSelectionListener(this);
     
    9290                multipolygon = new Multipolygon(r);
    9391                map2.put(r, multipolygon);
    94                 for (PolyData pd : multipolygon.getCombinedPolygons()) {
    95                     if (pd.isSelected()) {
    96                         selectedPolyData.add(pd);
     92                synchronized (this) {
     93                    for (PolyData pd : multipolygon.getCombinedPolygons()) {
     94                        if (pd.isSelected()) {
     95                            selectedPolyData.add(pd);
     96                        }
    9797                    }
    9898                }
     
    294294
    295295    @Override
    296     public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
     296    public synchronized void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
    297297
    298298        for (Iterator<PolyData> it = selectedPolyData.iterator(); it.hasNext();) {
Note: See TracChangeset for help on using the changeset viewer.