Changeset 13322 in josm


Ignore:
Timestamp:
2018-01-14T15:51:12+01:00 (7 months ago)
Author:
Don-vip
Message:

see #15767 - clear projection change listeners at the end of unit tests

Location:
trunk
Files:
2 edited

Legend:

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

    r13319 r13322  
    431431    public static void addProjectionChangeListener(ProjectionChangeListener listener) {
    432432        if (listener == null) return;
    433         synchronized (Main.class) {
    434             for (WeakReference<ProjectionChangeListener> wr : listeners) {
    435                 // already registered ? => abort
    436                 if (wr.get() == listener) return;
    437             }
    438             listeners.add(new WeakReference<>(listener));
    439         }
     433        for (WeakReference<ProjectionChangeListener> wr : listeners) {
     434            // already registered ? => abort
     435            if (wr.get() == listener) return;
     436        }
     437        listeners.add(new WeakReference<>(listener));
    440438    }
    441439
     
    447445    public static void removeProjectionChangeListener(ProjectionChangeListener listener) {
    448446        if (listener == null) return;
    449         synchronized (Main.class) {
    450             // remove the listener - and any other listener which got garbage
    451             // collected in the meantime
    452             listeners.removeIf(wr -> wr.get() == null || wr.get() == listener);
    453         }
     447        // remove the listener - and any other listener which got garbage collected in the meantime
     448        listeners.removeIf(wr -> wr.get() == null || wr.get() == listener);
     449    }
     450
     451    /**
     452     * Remove all projection change listeners. For testing purposes only.
     453     * @since 13322
     454     */
     455    public static void clearProjectionChangeListeners() {
     456        listeners.clear();
    454457    }
    455458
  • trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java

    r13300 r13322  
    510510
    511511        // TODO: Remove global listeners and other global state.
     512        Main.clearProjectionChangeListeners();
    512513        Main.pref.resetToInitialState();
    513514        Main.platform = null;
Note: See TracChangeset for help on using the changeset viewer.