Ticket #17401: 17401-v2.patch

File 17401-v2.patch, 3.3 KB (added by GerdP, 5 years ago)
  • src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java

     
    3434import org.openstreetmap.josm.actions.ValidateAction;
    3535import org.openstreetmap.josm.actions.relation.EditRelationAction;
    3636import org.openstreetmap.josm.command.Command;
     37import org.openstreetmap.josm.command.SequenceCommand;
    3738import org.openstreetmap.josm.data.UndoRedoHandler;
    3839import org.openstreetmap.josm.data.osm.DataSelectionListener;
    3940import org.openstreetmap.josm.data.osm.DataSet;
     
    601602            // do nothing
    602603        }
    603604
    604         protected void fixError(TestError error) throws InterruptedException, InvocationTargetException {
     605        protected void fixError(TestError error) {
    605606            if (error.isFixable()) {
    606607                final Command fixCommand = error.getFix();
    607608                if (fixCommand != null) {
    608                     SwingUtilities.invokeAndWait(() -> UndoRedoHandler.getInstance().addNoRedraw(fixCommand));
    609609                    fixCommands.add(fixCommand);
    610610                }
    611611                // It is wanted to ignore an error if it said fixable, even if fixCommand was null
     
    636636                    SwingUtilities.invokeAndWait(ds::endUpdate);
    637637                }
    638638                monitor.subTask(tr("Updating map ..."));
     639                List<TestError> oldErrors = new ArrayList<>(tree.getErrors());
     640                tree.getErrors().clear();
    639641                SwingUtilities.invokeAndWait(() -> {
    640                     UndoRedoHandler.getInstance().afterAdd(fixCommands);
     642                    UndoRedoHandler.getInstance().add(new SequenceCommand(tr("fixed by Validator"), fixCommands, true));
    641643                    invalidateValidatorLayers();
    642                     tree.resetErrors();
    643644                });
     645
     646                oldErrors.removeIf(error -> error.getPrimitives().stream().anyMatch(OsmPrimitive::isDeleted));
     647                tree.getErrors().addAll(oldErrors);
     648                tree.resetErrors();
    644649            } catch (InterruptedException | InvocationTargetException e) {
    645650                // FIXME: signature of realRun should have a generic checked exception we could throw here
    646651                throw new JosmRuntimeException(e);
  • src/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanel.java

     
    483483
    484484    @Override public void primitivesRemoved(PrimitivesRemovedEvent event) {
    485485        // Remove purged primitives (fix #8639)
    486         if (errors != null) {
    487             final Set<? extends OsmPrimitive> deletedPrimitives = new HashSet<>(event.getPrimitives());
    488             errors.removeIf(error -> error.getPrimitives().stream().anyMatch(deletedPrimitives::contains));
     486        if (errors != null && !errors.isEmpty()) {
     487            errors.removeIf(error -> error.getPrimitives().stream().anyMatch(OsmPrimitive::isDeleted));
    489488        }
    490489    }
    491490