Changeset 2515 in josm


Ignore:
Timestamp:
2009-11-25T17:58:39+01:00 (14 years ago)
Author:
hansendc
Message:

Fix ConcurrentModificationException on selListeners

http://josm.openstreetmap.de/ticket/3258

and some other duplicate bugs have run into this. This should
at least synchronize any modification operations with the
DataSet iteration. The only other concern would be if there
are other users around iterating over selListeners.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r2512 r2515  
    248248     * dataset. (However, the selection does only change in the active layer)
    249249     */
    250     public static Collection<SelectionChangedListener> selListeners = new LinkedList<SelectionChangedListener>();
     250    public static Collection<SelectionChangedListener> selListeners =
     251        Collections.synchronizedList(new LinkedList<SelectionChangedListener>());
    251252
    252253    /**
     
    257258     */
    258259    private static void notifySelectionChangeListeners(Collection<? extends OsmPrimitive> sel) {
    259         for (SelectionChangedListener l : selListeners) {
    260             l.selectionChanged(sel);
     260        synchronized (selListeners) {
     261            for (SelectionChangedListener l : selListeners) {
     262                l.selectionChanged(sel);
     263            }
    261264        }
    262265    }
Note: See TracChangeset for help on using the changeset viewer.