Changeset 18390 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2022-03-09T09:19:18+01:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/MainLayerManager.java
r18337 r18390 174 174 */ 175 175 public synchronized void addActiveLayerChangeListener(ActiveLayerChangeListener listener) { 176 if (activeLayerChangeListeners.contains(listener)) { 177 throw new IllegalArgumentException("Attempted to add listener that was already in list: " + listener); 176 for (int i = 0; i< activeLayerChangeListeners.size(); i++) { 177 if (activeLayerChangeListeners.get(i) == listener) { 178 Logging.error(""); 179 Logging.error("Attempted to add listener that was already in list: " + listener); 180 showStackTrace(Thread.currentThread().getStackTrace()); 181 return; 182 } 178 183 } 179 184 activeLayerChangeListeners.add(listener); 185 } 186 187 private void showStackTrace(StackTraceElement[] stackTrace) { 188 for (StackTraceElement st : stackTrace) { 189 Logging.error("\tat " + st); 190 } 180 191 } 181 192 … … 195 206 */ 196 207 public synchronized void removeActiveLayerChangeListener(ActiveLayerChangeListener listener) { 197 if (!activeLayerChangeListeners.contains(listener)) { 198 throw new IllegalArgumentException("Attempted to remove listener that was not in list: " + listener); 199 } 200 activeLayerChangeListeners.remove(listener); 208 int old = -1; 209 for (int i = 0; i < activeLayerChangeListeners.size(); i++) { 210 if (activeLayerChangeListeners.get(i) == listener) { 211 old = i; 212 break; 213 } 214 } 215 if (old < 0) { 216 Logging.error(""); 217 Logging.error("Attempted to remove listener that was not in list: " + listener); 218 showStackTrace(Thread.currentThread().getStackTrace()); 219 return; 220 } 221 activeLayerChangeListeners.remove(old); 201 222 } 202 223 … … 207 228 */ 208 229 public synchronized void addLayerAvailabilityListener(LayerAvailabilityListener listener) { 209 if (!layerAvailabilityListeners.add(listener)) { 210 throw new IllegalArgumentException("Attempted to add listener that was already in list: " + listener); 211 } 230 layerAvailabilityListeners.add(listener); 212 231 } 213 232
Note:
See TracChangeset
for help on using the changeset viewer.