Changeset 17406 in josm for trunk/src


Ignore:
Timestamp:
2020-12-13T16:04:00+01:00 (4 years ago)
Author:
GerdP
Message:

fix #20230: update multipolygon action removes tags from ways without adding them to relation

  • create ChangeCommand if tags of updated relation were changed

Todo: refactoring to remove class CreateUpdateMultipolygonTask

File:
1 edited

Legend:

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

    r17358 r17406  
    2626import org.openstreetmap.josm.actions.relation.DownloadSelectedIncompleteMembersAction;
    2727import org.openstreetmap.josm.command.AddCommand;
     28import org.openstreetmap.josm.command.ChangeCommand;
    2829import org.openstreetmap.josm.command.ChangeMembersCommand;
    2930import org.openstreetmap.josm.command.ChangePropertyCommand;
     
    112113                return;
    113114            }
    114             final Command command = commandAndRelation.a;
    115115
    116116            // to avoid EDT violations
    117117            SwingUtilities.invokeLater(() -> {
    118                 if (multipolygonRelation != null) {
    119                     // rather ugly: update generated a ChangeMembersCommand with a copy of the member list, so clear the list now
    120                     commandAndRelation.b.setMembers(null); // #see 19885
    121                 }
    122                 UndoRedoHandler.getInstance().add(command);
     118                UndoRedoHandler.getInstance().add(commandAndRelation.a);
     119                Relation calculatedRel = commandAndRelation.b;
     120                if (calculatedRel.getDataSet() == null) {
     121                    calculatedRel.setMembers(null); // see #19885
     122                }
    123123                final Relation relation = (Relation) MainApplication.getLayerManager().getEditDataSet()
    124                         .getPrimitiveById(commandAndRelation.b);
     124                        .getPrimitiveById(calculatedRel);
    125125                if (relation == null || relation.getDataSet() == null)
    126126                    return; // should not happen
     
    350350        } else {
    351351            if (!unchanged) {
    352                 list.add(new ChangeMembersCommand(existingRelation, new ArrayList<>(relation.getMembers())));
     352                if (relation.getKeys().equals(existingRelation.getKeys()))
     353                    list.add(new ChangeMembersCommand(existingRelation, new ArrayList<>(relation.getMembers())));
     354                else
     355                    list.add(new ChangeCommand(existingRelation, relation));
    353356            }
    354357            if (list.isEmpty()) {
Note: See TracChangeset for help on using the changeset viewer.