Changeset 12349 in josm


Ignore:
Timestamp:
2017-06-08T23:50:37+02:00 (8 months ago)
Author:
michael2402
Message:

Fix SelectCommand triggering a critical error when it is undone after the edit layer was changed.

File:
1 edited

Legend:

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

    r10663 r12349  
    99import java.util.Objects;
    1010
    11 import org.openstreetmap.josm.Main;
     11import org.openstreetmap.josm.data.osm.DataSet;
    1212import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1313
     
    3737    }
    3838
     39    /**
     40     * Constructs a new select command.
     41     * @param dataset The dataset the selection belongs to
     42     * @param newSelection the primitives to select when executing the command.
     43     * @since 12349
     44     */
     45    public SelectCommand(DataSet dataset, Collection<OsmPrimitive> newSelection) {
     46        super(dataset);
     47        if (newSelection == null || newSelection.isEmpty()) {
     48            this.newSelection = Collections.emptySet();
     49        } else {
     50            this.newSelection = new HashSet<>(newSelection);
     51        }
     52    }
     53
    3954    @Override
    4055    public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
     
    4459    @Override
    4560    public void undoCommand() {
    46         Main.getLayerManager().getEditLayer().data.setSelected(oldSelection);
     61        getAffectedDataSet().setSelected(oldSelection);
    4762    }
    4863
    4964    @Override
    5065    public boolean executeCommand() {
    51         oldSelection = Main.getLayerManager().getEditLayer().data.getSelected();
    52         Main.getLayerManager().getEditLayer().data.setSelected(newSelection);
     66        oldSelection = getAffectedDataSet().getSelected();
     67        getAffectedDataSet().setSelected(newSelection);
    5368        return true;
    5469    }
Note: See TracChangeset for help on using the changeset viewer.