Changeset 2343 in josm for trunk/src/org


Ignore:
Timestamp:
2009-10-28T20:14:07+01:00 (14 years ago)
Author:
Gubaer
Message:

fixed #3792: NPE when deleting the data layer while the deletion tool is active

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

Legend:

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

    r2328 r2343  
    7070
    7171abstract public class Main {
     72   
     73    /**
     74     * Replies true if JOSM currently displays a map view. False, if it doesn't, i.e. if
     75     * it only shows the MOTD panel.
     76     *
     77     * @return true if JOSM currently displays a map view
     78     */
     79    static public boolean isDisplayingMapView() {
     80        if (map == null) return false;
     81        if (map.mapView == null) return false;
     82        return true;
     83    }
    7284    /**
    7385     * Global parent component for all dialogs and message boxes
  • trunk/src/org/openstreetmap/josm/actions/AbstractMergeAction.java

    r2032 r2343  
    3333
    3434        protected boolean isActiveLayer(Layer layer) {
    35             if (Main.map == null)
    36                 return false;
    37             if (Main.map.mapView == null)
    38                 return false;
     35            if (Main.isDisplayingMapView()) return false;
    3936            return Main.map.mapView.getActiveLayer() == layer;
    4037        }
  • trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java

    r2323 r2343  
    181181        } else {
    182182            setEnabled(
    183                     Main.map != null
    184                     && Main.map.mapView != null
     183                    Main.isDisplayingMapView()
    185184                    && Main.map.mapView.hasLayers()
    186185            );
  • trunk/src/org/openstreetmap/josm/actions/DownloadReferrersAction.java

    r2323 r2343  
    9292
    9393    public void actionPerformed(ActionEvent e) {
    94         if (!isEnabled() || Main.map == null || Main.map.mapView == null)
     94        if (!isEnabled() || ! Main.isDisplayingMapView())
    9595            return;
    9696        OsmDataLayer layer = Main.map.mapView.getEditLayer();
  • trunk/src/org/openstreetmap/josm/actions/GpxExportAction.java

    r2323 r2343  
    3333
    3434    protected GpxLayer getLayer() {
    35         if (Main.map == null) return null;
    36         if (Main.map.mapView == null) return null;
     35        if (!Main.isDisplayingMapView()) return null;
    3736        if (Main.map.mapView.getActiveLayer() == null) return null;
    3837        Layer layer = Main.map.mapView.getActiveLayer();
     
    9594    @Override
    9695    protected void updateEnabledState() {
    97         boolean check = Main.main != null
    98         && Main.map != null
    99         && Main.map.mapView !=null
     96        boolean check =           
     97        Main.isDisplayingMapView()
    10098        && Main.map.mapView.getActiveLayer() != null;
    10199        if(!check) {
  • trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java

    r2273 r2343  
    3636    public boolean doSave() {
    3737        Layer layer = null;
    38         if (Main.map != null && (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer
     38        if (Main.isDisplayingMapView() && (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer
    3939                || Main.map.mapView.getActiveLayer() instanceof GpxLayer)) {
    4040            layer = Main.map.mapView.getActiveLayer();
  • trunk/src/org/openstreetmap/josm/actions/ZoomInAction.java

    r2323 r2343  
    2020
    2121    public void actionPerformed(ActionEvent e) {
    22         if (Main.map == null) return;
     22        if (!Main.isDisplayingMapView()) return;
    2323        Main.map.mapView.zoomToFactor(0.9);
    2424    }
     
    2727    protected void updateEnabledState() {
    2828        setEnabled(
    29                 Main.map != null
    30                 && Main.map.mapView != null
     29                Main.isDisplayingMapView()
    3130                && Main.map.mapView.hasLayers()
    3231        );
  • trunk/src/org/openstreetmap/josm/actions/ZoomOutAction.java

    r2323 r2343  
    2020
    2121    public void actionPerformed(ActionEvent e) {
    22         if (Main.map == null) return;
     22        if (!Main.isDisplayingMapView()) return;
    2323        Main.map.mapView.zoomToFactor(1/0.9);
    2424    }
     
    2727    protected void updateEnabledState() {
    2828        setEnabled(
    29                 Main.map != null
    30                 && Main.map.mapView != null
     29                Main.isDisplayingMapView()
    3130                && Main.map.mapView.hasLayers()
    3231        );
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java

    r2328 r2343  
    8787        private Layer findMergeLayer() {
    8888            boolean merge = Main.pref.getBoolean("download.gps.mergeWithLocal", false);
    89             if (Main.map == null)
     89            if (!Main.isDisplayingMapView())   
    9090                return null;
    9191            Layer active = Main.map.mapView.getActiveLayer();
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

    r2328 r2343  
    104104
    105105        protected OsmDataLayer getEditLayer() {
    106             if (Main.map == null) return null;
    107             if (Main.map.mapView == null) return null;
     106            if (!Main.isDisplayingMapView()) return null;
    108107            return Main.map.mapView.getEditLayer();
    109108        }
     
    111110        protected int getNumDataLayers() {
    112111            int count = 0;
    113             if (Main.map == null) return 0;
    114             if (Main.map.mapView == null) return 0;
     112            if (!Main.isDisplayingMapView()) return 0;
    115113            Collection<Layer> layers = Main.map.mapView.getAllLayers();
    116114            for (Layer layer : layers) {
     
    123121
    124122        protected OsmDataLayer getFirstDataLayer() {
    125             if (Main.map == null) return null;
    126             if (Main.map.mapView == null) return null;
     123            if (!Main.isDisplayingMapView()) return null;
    127124            Collection<Layer> layers = Main.map.mapView.getAllLayersAsList();
    128125            for (Layer layer : layers) {
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java

    r2308 r2343  
    176176     */
    177177    private void updateCursor(MouseEvent e, int modifiers) {
     178        if (!Main.isDisplayingMapView()) {
     179            return;
     180        }
    178181        if(!Main.map.mapView.isActiveLayerVisible() || e == null)
    179182            return;
Note: See TracChangeset for help on using the changeset viewer.