Ignore:
Timestamp:
2010-08-15T22:04:43+02:00 (14 years ago)
Author:
jttt
Message:

Fix some of the references/forgotten listeners that keeps MapView alive after all layers are removed (see #5331)

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
3 edited

Legend:

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

    r3083 r3443  
    2424public abstract class AbstractInfoAction extends JosmAction {
    2525
    26     public AbstractInfoAction() {
    27         super();
     26    public AbstractInfoAction(boolean installAdapters) {
     27        super(installAdapters);
    2828    }
    2929
  • trunk/src/org/openstreetmap/josm/actions/JosmAction.java

    r3416 r3443  
    6666     */
    6767    public JosmAction(String name, String iconName, String tooltip, Shortcut shortcut, boolean register) {
     68        this(name, iconName, tooltip, shortcut, register, true);
     69    }
     70
     71    /**
     72     * Even newer super for all actions. Use if you don't want to install layer changed and selection changed adapters
     73     * @param name
     74     * @param iconName
     75     * @param tooltip
     76     * @param shortcut
     77     * @param register
     78     * @param installAdapters
     79     */
     80    public JosmAction(String name, String iconName, String tooltip, Shortcut shortcut, boolean register, boolean installAdapters) {
    6881        super(name, iconName == null ? null : ImageProvider.get(iconName));
    6982        setHelpId();
     
    7790            Main.toolbar.register(this);
    7891        }
    79         installAdapters();
     92        if (installAdapters) {
     93            installAdapters();
     94        }
    8095    }
    8196
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ZoomAction.java

    r2512 r3443  
    77import java.awt.event.KeyEvent;
    88
     9import org.openstreetmap.josm.Main;
    910import org.openstreetmap.josm.gui.MapFrame;
    1011import org.openstreetmap.josm.gui.MapView;
     
    3031
    3132    /**
    32      * Shortcut to the mapview.
    33      */
    34     private final MapView mv;
    35     /**
    3633     * Manager that manages the selection rectangle with the aspect ratio of the
    3734     * MapView.
     
    4744                Shortcut.registerShortcut("mapmode:zoom", tr("Mode: {0}", tr("Zoom")), KeyEvent.VK_Z, Shortcut.GROUP_EDIT),
    4845                mapFrame, ImageProvider.getCursor("normal", "zoom"));
    49         mv = mapFrame.mapView;
    50         selectionManager = new SelectionManager(this, true, mv);
     46        selectionManager = new SelectionManager(this, true, mapFrame.mapView);
    5147    }
    5248
     
    5551     */
    5652    public void selectionEnded(Rectangle r, boolean alt, boolean shift, boolean ctrl) {
    57         if (r.width >= 3 && r.height >= 3) {
     53        if (r.width >= 3 && r.height >= 3 && Main.isDisplayingMapView()) {
     54            MapView mv = Main.map.mapView;
    5855            mv.zoomToFactor(mv.getEastNorth(r.x+r.width/2, r.y+r.height/2), r.getWidth()/mv.getWidth());
    5956        }
     
    6259    @Override public void enterMode() {
    6360        super.enterMode();
    64         selectionManager.register(mv);
     61        selectionManager.register(Main.map.mapView);
    6562    }
    6663
    6764    @Override public void exitMode() {
    6865        super.exitMode();
    69         selectionManager.unregister(mv);
     66        selectionManager.unregister(Main.map.mapView);
    7067    }
    7168
Note: See TracChangeset for help on using the changeset viewer.