Ticket #22808: 22808.patch

File 22808.patch, 1.3 KB (added by GerdP, 21 months ago)

quick hack to work around the update selection problem

  • src/org/openstreetmap/josm/command/AddPrimitivesCommand.java

     
    55
    66import java.util.ArrayList;
    77import java.util.Collection;
     8import java.util.LinkedHashSet;
    89import java.util.List;
    910import java.util.Objects;
    1011import java.util.Optional;
     12import java.util.Set;
    1113import java.util.stream.Collectors;
    1214
    1315import javax.swing.Icon;
     
    126128            }
    127129            createdPrimitives = PurgeCommand.topoSort(createdPrimitives);
    128130        }
     131        // clear selection to improve performance, see #22808
     132        Set<OsmPrimitive> clearedSelection = new LinkedHashSet<>(ds.getSelected());
     133        clearedSelection.removeAll(createdPrimitives);
     134        ds.clearSelection();
     135
    129136        // reversed order, see #14620
    130137        for (int i = createdPrimitives.size() - 1; i >= 0; i--) {
    131138            OsmPrimitive osm = createdPrimitives.get(i);
     
    137144                ds.removePrimitive(osm);
    138145            }
    139146        }
     147        // select still existing objects of old selection
     148        ds.setSelected(clearedSelection);
    140149    }
    141150
    142151    @Override