Changeset 3444 in josm for trunk


Ignore:
Timestamp:
2010-08-17T08:08:58+02:00 (14 years ago)
Author:
jttt
Message:

Fix #5331 Memory leak when removing data layers

Location:
trunk/src/org/openstreetmap/josm
Files:
5 edited

Legend:

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

    r3433 r3444  
    3636import javax.swing.UIManager;
    3737
     38import org.openstreetmap.josm.actions.JosmAction;
    3839import org.openstreetmap.josm.actions.OpenFileAction;
    3940import org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTask;
     
    313314    }
    314315
     316    public static void unregisterActionShortcut(JosmAction action) {
     317        unregisterActionShortcut(action, action.getShortcut());
     318    }
     319
     320    public static void unregisterActionShortcut(Action action, Shortcut shortcut) {
     321        contentPanePrivate.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).remove(shortcut.getKeyStroke());
     322        contentPanePrivate.getActionMap().remove(action);
     323    }
     324
     325
    315326    ///////////////////////////////////////////////////////////////////////////
    316327    //  Implementation part
  • trunk/src/org/openstreetmap/josm/actions/JosmAction.java

    r3443 r3444  
    108108    public void destroy() {
    109109        if (sc != null) {
    110             Main.unregisterActionShortcut(sc);
     110            Main.unregisterActionShortcut(this);
    111111        }
    112112        MapView.removeLayerChangeListener(layerChangeAdapter);
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r3262 r3444  
    6363    //static private final Logger logger = Logger.getLogger(SelectAction.class.getName());
    6464
    65     /**
    66      * Replies true if we are currently running on OSX
    67      *
    68      * @return true if we are currently running on OSX
    69      */
    70     public static boolean isPlatformOsx() {
    71         return Main.platform != null
    72         && Main.platform instanceof PlatformHookOsx;
    73     }
    74 
    7565    enum Mode { move, rotate, select }
    7666    private Mode mode = null;
     
    274264        // Mac OSX simulates with  ctrl + mouse 1  the second mouse button hence no dragging events get fired.
    275265        //
    276         if (isPlatformOsx() && mode == Mode.rotate) {
     266        if ((Main.platform instanceof PlatformHookOsx) && mode == Mode.rotate) {
    277267            mouseDragged(e);
    278268        }
     
    490480                        if (!nodesToMerge.isEmpty()) {
    491481                            Command cmd = MergeNodesAction.mergeNodes(Main.main.getEditLayer(),nodesToMerge, targetNode);
    492                             if(cmd != null)
     482                            if(cmd != null) {
    493483                                Main.main.undoRedo.add(cmd);
     484                            }
    494485                        }
    495486                    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/HistoryDialog.java

    r3416 r3444  
    7171                        Shortcut.GROUP_LAYER, Shortcut.SHIFT_DEFAULT), 150);
    7272        build();
    73         DataSet.addSelectionListener(model);
    74 
    7573        HelpUtil.setHelpContext(this, HelpUtil.ht("/Dialog/HistoryDialog"));
    7674    }
     
    142140    public void showNotify() {
    143141        HistoryDataSet.getInstance().addHistoryDataSetListener(this);
     142        DataSet.addSelectionListener(model);
    144143    }
    145144
     
    147146    public void hideNotify() {
    148147        HistoryDataSet.getInstance().removeHistoryDataSetListener(this);
     148        DataSet.removeSelectionListener(model);
    149149    }
    150150
     
    278278     */
    279279    class ReloadAction extends AbstractAction implements ListSelectionListener {
     280
    280281        public ReloadAction() {
    281282            putValue(Action.SMALL_ICON, ImageProvider.get("dialogs","refresh"));
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r3431 r3444  
    151151    // button in the upper right corner of this dialog
    152152    public static JPanel pluginHook = new JPanel();
    153    
     153
    154154    private final Map<String, Map<String, Integer>> valueCount = new TreeMap<String, Map<String, Integer>>();
    155155
     
    179179        SelectionEventManager.getInstance().removeSelectionListener(this);
    180180        MapView.removeEditLayerChangeListener(this);
    181         Main.unregisterActionShortcut(addActionShortcut);
     181        Main.unregisterActionShortcut(addAction, addActionShortcut);
    182182    }
    183183
Note: See TracChangeset for help on using the changeset viewer.