Ticket #6876: parallel-mode-nullpointer-exception-no-edit-layer.patch

File parallel-mode-nullpointer-exception-no-edit-layer.patch, 1.6 KB (added by olejorgenb, 13 years ago)
  • src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java

    diff --git a/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java b/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java
    index be2f538..4f4885f 100644
    a b public class ParallelWayAction extends MapMode implements AWTEventListener, MapV  
    131131
    132132    @Override
    133133    public void enterMode() {
    134         // super.enterMode() updates the status line and cursor so we need our state to be set correctly
     134        if (!isEnabled())
     135            return;
     136        // super.enterMode() updates the status line and cursor so we need our state to be set correctly early
    135137        setMode(Mode.normal);
    136138        pWays = null;
    137139        updateAllPreferences(); // All default values should've been set now
    public class ParallelWayAction extends MapMode implements AWTEventListener, MapV  
    147149            Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK);
    148150        } catch (SecurityException ex) {
    149151        }
     152
    150153        sourceWays = new LinkedHashSet<Way>(getCurrentDataSet().getSelectedWays());
    151154        for (Way w : sourceWays) {
    152155            w.setHighlighted(true);
    public class ParallelWayAction extends MapMode implements AWTEventListener, MapV  
    214217    }
    215218
    216219    @Override
     220    protected void updateEnabledState() {
     221        setEnabled(getEditLayer() != null);
     222    }
     223
     224    @Override
    217225    public void eventDispatched(AWTEvent e) {
    218226        if (Main.map == null || mv == null || !mv.isActiveLayerDrawable())
    219227            return;