Ticket #19199: 19199.threading.1.patch

File 19199.threading.1.patch, 1.9 KB (added by taylor.smock, 5 years ago)

Update patch to current source (line number change only)

  • src/org/openstreetmap/josm/actions/SimplifyWayAction.java

     
    4646import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec;
    4747import org.openstreetmap.josm.gui.MainApplication;
    4848import org.openstreetmap.josm.gui.Notification;
     49import org.openstreetmap.josm.gui.util.GuiHelper;
    4950import org.openstreetmap.josm.spi.preferences.Config;
    5051import org.openstreetmap.josm.spi.preferences.IPreferences;
    5152import org.openstreetmap.josm.tools.GBC;
    public class SimplifyWayAction extends JosmAction {  
    512513                UndoRedoHandler.getInstance().undo();
    513514            }
    514515            double threshold = errorModel.getNumber().doubleValue();
     516            MainApplication.worker.submit(() -> updateNodesToRemove(this.ways, threshold));
     517        }
     518
     519        private synchronized void updateNodesToRemove(List<Way> ways, double threshold) {
     520            if (lastCommand != null && lastCommand.equals(UndoRedoHandler.getInstance().getLastCommand())) {
     521                GuiHelper.runInEDTAndWait(() -> UndoRedoHandler.getInstance().undo());
     522            }
    515523            int removeNodes = simplifyWaysCountNodesRemoved(ways, threshold);
     524            GuiHelper.runInEDTAndWait(() -> {
    516525            nodesToRemove.setText(trn(
    517526                    "(about {0} node to remove)",
    518527                    "(about {0} nodes to remove)", removeNodes, removeNodes));
     528            });
    519529            lastCommand = SimplifyWayAction.buildSimplifyWaysCommand(ways, threshold);
    520530            if (lastCommand != null) {
    521                 UndoRedoHandler.getInstance().add(lastCommand);
     531                GuiHelper.runInEDTAndWait(() -> UndoRedoHandler.getInstance().add(lastCommand));
    522532            }
    523533        }
    524534    }