Changeset 10958 in josm


Ignore:
Timestamp:
2016-09-04T17:27:29+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #13479 - safer management of listeners

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialog.java

    r10957 r10958  
    3636
    3737    private final ApplyResolutionAction applyResolutionAction = new ApplyResolutionAction();
     38
     39    private boolean isRegistered;
    3840
    3941    /**
     
    6567    }
    6668
    67     private void registerListeners() {
    68         resolver.addPropertyChangeListener(applyResolutionAction);
    69         resolver.registerListeners();
    70     }
    71 
    72     private void unregisterListeners() {
    73         resolver.removePropertyChangeListener(applyResolutionAction);
    74         resolver.unregisterListeners();
     69    private synchronized void registerListeners() {
     70        if (!isRegistered) {
     71            resolver.addPropertyChangeListener(applyResolutionAction);
     72            resolver.registerListeners();
     73            isRegistered = true;
     74        }
     75    }
     76
     77    private synchronized void unregisterListeners() {
     78        // See #13479 - See https://bugs.openjdk.java.net/browse/JDK-4387314
     79        // Owner window keep a list of owned windows, and does not remove the references when the child is disposed.
     80        // There's no easy way to remove ourselves from this list, so we must keep track of register state
     81        if (isRegistered) {
     82            resolver.removePropertyChangeListener(applyResolutionAction);
     83            resolver.unregisterListeners();
     84            isRegistered = false;
     85        }
    7586    }
    7687
Note: See TracChangeset for help on using the changeset viewer.