Ignore:
Timestamp:
2015-01-09T11:35:10+01:00 (5 years ago)
Author:
Don-vip
Message:

see #10953 - fix crash and EDT violation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java

    r7668 r7945  
    3636import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationTask;
    3737import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor;
     38import org.openstreetmap.josm.gui.util.GuiHelper;
    3839import org.openstreetmap.josm.tools.Pair;
    3940import org.openstreetmap.josm.tools.Shortcut;
     
    8485        private final Relation multipolygonRelation;
    8586
    86         public CreateUpdateMultipolygonTask(Collection<Way> selectedWays, Relation multipolygonRelation) {
     87        private CreateUpdateMultipolygonTask(Collection<Way> selectedWays, Relation multipolygonRelation) {
    8788            this.selectedWays = selectedWays;
    8889            this.multipolygonRelation = multipolygonRelation;
     
    140141        final Collection<Relation> selectedRelations = Main.main.getCurrentDataSet().getSelectedRelations();
    141142
    142         if (selectedWays.size() < 1) {
     143        if (selectedWays.isEmpty()) {
    143144            // Sometimes it make sense creating multipoly of only one way (so it will form outer way)
    144145            // and then splitting the way later (so there are multiple ways forming outer way)
     
    156157
    157158        // download incomplete relation if necessary
    158         if (multipolygonRelation != null && (multipolygonRelation.isIncomplete() || multipolygonRelation.hasIncompleteMembers())) {
     159        if (multipolygonRelation != null && !multipolygonRelation.isNew()
     160                && (multipolygonRelation.isIncomplete() || multipolygonRelation.hasIncompleteMembers())) {
    159161            Main.worker.submit(new DownloadRelationTask(Collections.singleton(multipolygonRelation), Main.main.getEditLayer()));
    160162        }
    161163        // create/update multipolygon relation
    162164        Main.worker.submit(new CreateUpdateMultipolygonTask(selectedWays, multipolygonRelation));
    163 
    164165    }
    165166
     
    172173            return selectedRelations.iterator().next();
    173174        } else {
    174             final HashSet<Relation> relatedRelations = new HashSet<>();
     175            final Set<Relation> relatedRelations = new HashSet<>();
    175176            for (final Way w : selectedWays) {
    176177                relatedRelations.addAll(Utils.filteredCollection(w.getReferrers(), Relation.class));
     
    268269
    269270        MultipolygonBuilder pol = new MultipolygonBuilder();
    270         String error = pol.makeFromWays(selectedWays);
     271        final String error = pol.makeFromWays(selectedWays);
    271272
    272273        if (error != null) {
    273274            if (showNotif) {
    274                 new Notification(error)
     275                GuiHelper.runInEDT(new Runnable() {
     276                    @Override
     277                    public void run() {
     278                        new Notification(error)
    275279                        .setIcon(JOptionPane.INFORMATION_MESSAGE)
    276280                        .show();
     281                    }
     282                });
    277283            }
    278284            return null;
     
    303309    private static void addMembers(JoinedPolygon polygon, Relation rel, String role) {
    304310        final int count = rel.getMembersCount();
    305         final HashSet<Way> ways = new HashSet<>(polygon.ways);
     311        final Set<Way> ways = new HashSet<>(polygon.ways);
    306312        for (int i = 0; i < count; i++) {
    307313            final RelationMember m = rel.getMember(i);
Note: See TracChangeset for help on using the changeset viewer.