Changeset 14548 in josm for trunk


Ignore:
Timestamp:
2018-12-10T17:04:09+01:00 (6 years ago)
Author:
GerdP
Message:

see #17040 - destroy AddImageryLayerAction

Up to now they were never destroyed, and one is created for each available entry in ImageryMenu whenever you open the menu.

File:
1 edited

Legend:

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

    r14248 r14548  
    154154        savedLayers.sort(alphabeticImageryComparator);
    155155        for (final ImageryInfo u : savedLayers) {
    156             addDynamic(new AddImageryLayerAction(u));
     156            addDynamic(trackJosmAction(new AddImageryLayerAction(u)));
    157157        }
    158158
     
    189189                addDynamicSeparator();
    190190                for (ImageryInfo i : inViewLayers) {
    191                     addDynamic(new AddImageryLayerAction(i));
     191                    addDynamic(trackJosmAction(new AddImageryLayerAction(i)));
    192192                }
    193193            }
     
    262262     */
    263263    private final List<Object> dynamicItems = new ArrayList<>(20);
     264    private final List<JosmAction> dynJosmActions = new ArrayList<>(20);
    264265
    265266    /**
     
    268269     */
    269270    private void removeDynamicItems() {
     271        dynJosmActions.forEach(JosmAction::destroy);
     272        dynJosmActions.clear();
    270273        for (Object item : dynamicItems) {
    271274            if (item instanceof JMenuItem) {
     
    294297        dynamicItems.add(this.add(it));
    295298    }
     299
     300    private Action trackJosmAction(Action action) {
     301        if (action instanceof JosmAction) {
     302            dynJosmActions.add((JosmAction) action);
     303        }
     304        return action;
     305    }
     306
    296307}
Note: See TracChangeset for help on using the changeset viewer.