Changeset 35942 in osm for applications/editors


Ignore:
Timestamp:
2022-03-22T22:32:08+01:00 (3 years ago)
Author:
taylor.smock
Message:

fix #16641: Listener CommandLine.LengthAction was not registered before or already removed

This was caused by the exitMode() being called on mode change AND on drawing
finish.

This patch also improves user feedback when a command errors out. For example,
when python isn't installed.

Location:
applications/editors/josm/plugins/CommandLine/src/org/openstreetmap/josm/plugins/commandline
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/CommandLine/src/org/openstreetmap/josm/plugins/commandline/CommandLine.java

    r35705 r35942  
    2121import java.nio.file.StandardCopyOption;
    2222import java.util.ArrayList;
    23 import java.util.Arrays;
    2423import java.util.Collection;
    2524import java.util.List;
     
    4746import org.openstreetmap.josm.gui.MainMenu;
    4847import org.openstreetmap.josm.gui.MapFrame;
     48import org.openstreetmap.josm.gui.Notification;
    4949import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    5050import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer;
     
    5252import org.openstreetmap.josm.gui.layer.ImageryLayer;
    5353import org.openstreetmap.josm.gui.layer.Layer;
     54import org.openstreetmap.josm.gui.util.GuiHelper;
    5455import org.openstreetmap.josm.gui.widgets.DisableShortcutsOnFocusGainedTextField;
    5556import org.openstreetmap.josm.io.GpxWriter;
     
    497498            tp.process = builder.start();
    498499        } catch (final IOException e) {
     500            final String errorText;
    499501            synchronized (debugstr) {
    500                 Logging.error(
    501                         tr("Error executing the script:") + ' ' +
    502                         debugstr.toString() + e.getMessage() + '\n' + Arrays.toString(e.getStackTrace()));
    503             }
     502                errorText = tr("Error executing the script:") + ' ' + debugstr + e.getMessage();
     503            }
     504            Logging.error(errorText);
     505            Logging.error(e);
     506            GuiHelper.runInEDT(() ->
     507                new Notification(errorText).setIcon(JOptionPane.ERROR_MESSAGE).setDuration(Notification.TIME_LONG).show()
     508            );
     509            setMode(Mode.IDLE);
    504510            return;
    505511        }
  • applications/editors/josm/plugins/CommandLine/src/org/openstreetmap/josm/plugins/commandline/LengthAction.java

    r35297 r35942  
    152152        drawStartPos = null;
    153153        drawing = false;
    154         exitMode();
     154        // exitMode is called when we change to a different action. Do not call it here.
    155155    }
    156156
Note: See TracChangeset for help on using the changeset viewer.