Changeset 30072 in osm for applications/editors


Ignore:
Timestamp:
2013-11-20T21:53:52+01:00 (11 years ago)
Author:
donvip
Message:

[josm_terracer] fix #josm8942 - Crash of Terracer Plugin

Location:
applications/editors/josm/plugins/terracer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/terracer/build.xml

    r29854 r30072  
    22<project name="terracer" default="dist" basedir=".">
    33    <property name="commit.message" value="applied #j5760 (patch by robome) - Order of housenumbers not correct"/>
    4     <property name="plugin.main.version" value="6162"/>
     4    <property name="plugin.main.version" value="6397"/>
    55    <property name="plugin.author" value="Matt Amos"/>
    66    <property name="plugin.class" value="terracer.TerracerPlugin"/>
  • applications/editors/josm/plugins/terracer/src/terracer/TerracerAction.java

    r29623 r30072  
    7070
    7171    Collection<Command> commands;
     72   
     73    private Collection<OsmPrimitive> primitives;
     74    private TagCollection tagsInConflict;
    7275
    7376    public TerracerAction() {
     
    315318     * @throws UserCancelException
    316319     */
    317     public void terraceBuilding(Way outline,
     320    public void terraceBuilding(final Way outline,
    318321                Node init,
    319322                Way street,
     
    457460        }
    458461
    459         Main.main.undoRedo.add(new SequenceCommand(tr("Terrace"), commands));
     462        Main.main.undoRedo.add(new SequenceCommand(tr("Terrace"), commands) {
     463            @Override
     464            public boolean executeCommand() {
     465                boolean result = super.executeCommand();
     466                if (result) {
     467                    try {
     468                        // Build conflicts commands only after all primitives have been added to dataset to fix #8942
     469                        List<Command> conflictCommands = CombinePrimitiveResolverDialog.launchIfNecessary(
     470                                tagsInConflict, primitives, Collections.singleton(outline));
     471                        if (!conflictCommands.isEmpty()) {
     472                            List<Command> newCommands = new ArrayList<Command>(commands);
     473                            newCommands.addAll(conflictCommands);
     474                            setSequence(newCommands.toArray(new Command[0]));
     475                            // Run conflicts commands
     476                            for (int i = 0; i < conflictCommands.size(); i++) {
     477                                result = conflictCommands.get(i).executeCommand();
     478                                if (!result && !continueOnError) {
     479                                    setSequenceComplete(false);
     480                                    undoCommands(commands.size()+i-1);
     481                                    return false;
     482                                }
     483                            }
     484                        }
     485                    } catch (UserCancelException e) {
     486                        // Ignore
     487                    }
     488                }
     489                return result;
     490            }
     491        });
    460492        if (nb <= 1 && street != null) {
    461493            // Select the way (for quick selection of a new house (with the same way))
     
    483515        boolean numberAdded = false;
    484516        if (houseNum != null) {
    485             Collection<OsmPrimitive> primitives = Arrays.asList(new OsmPrimitive[]{houseNum, outline});
     517            primitives = Arrays.asList(new OsmPrimitive[]{houseNum, outline});
    486518           
    487519            TagCollection tagsToCopy = TagCollection.unionOfAllPrimitives(primitives).getTagsFor(houseNum.keySet());
    488             TagCollection tagsInConflict = tagsToCopy.getTagsFor(tagsToCopy.getKeysWithMultipleValues());
     520            tagsInConflict = tagsToCopy.getTagsFor(tagsToCopy.getKeysWithMultipleValues());
    489521            tagsToCopy = tagsToCopy.minus(tagsInConflict).minus(TagCollection.from(outline));
    490522           
     
    492524                this.commands.add(new ChangePropertyCommand(outline, tag.getKey(), tag.getValue()));
    493525            }
    494            
    495             this.commands.addAll(CombinePrimitiveResolverDialog.launchIfNecessary(
    496                     tagsInConflict, primitives, Collections.singleton(outline)));
    497526           
    498527            buildingAdded = houseNum.hasKey("building");
Note: See TracChangeset for help on using the changeset viewer.