Changeset 17358 in josm for trunk/src/org/openstreetmap/josm/command/SplitWayCommand.java
- Timestamp:
- 2020-11-25T11:50:22+01:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/command/SplitWayCommand.java
r17163 r17358 17 17 import java.util.HashSet; 18 18 import java.util.Iterator; 19 import java.util.LinkedHashSet; 19 20 import java.util.LinkedList; 20 21 import java.util.List; … … 90 91 * @param newSelection The new list of selected primitives ids (which is saved for later retrieval with {@link #getNewSelection}) 91 92 * @param originalWay The original way being split (which is saved for later retrieval with {@link #getOriginalWay}) 92 * @param newWays The resulting new ways (which is saved for later retrieval with {@link #get OriginalWay})93 * @param newWays The resulting new ways (which is saved for later retrieval with {@link #getNewWays}) 93 94 */ 94 95 public SplitWayCommand(String name, Collection<Command> commandList, … … 402 403 } catch (OsmTransferException e) { 403 404 ExceptionDialogUtil.explainException(e); 405 analysis.cleanup(); 404 406 return Optional.empty(); 405 407 } 406 408 // If missing relation members were downloaded, perform the analysis again to find the relation 407 409 // member order for all relations. 410 analysis.cleanup(); 408 411 analysis = analyseSplit(way, wayToKeep, newWays); 409 return Optional.of(splitBasedOnAnalyses(way, newWays, newSelection, analysis, indexOfWayToKeep));412 break; 410 413 case GO_AHEAD_WITHOUT_DOWNLOADS: 411 414 // Proceed with the split with the information we have. 412 415 // This can mean that there are no missing members we want, or that the user chooses to continue 413 416 // the split without downloading them. 414 return Optional.of(splitBasedOnAnalyses(way, newWays, newSelection, analysis, indexOfWayToKeep));417 break; 415 418 case USER_ABORTED: 416 419 default: 417 420 return Optional.empty(); 421 } 422 try { 423 return Optional.of(splitBasedOnAnalyses(way, newWays, newSelection, analysis, indexOfWayToKeep)); 424 } finally { 425 // see #19885 426 wayToKeep.setNodes(null); 427 analysis.cleanup(); 418 428 } 419 429 } … … 465 475 } 466 476 if (c == null) { 467 c = new Relation(r); 477 c = new Relation(r); // #19885: will be removed later 468 478 } 469 479 … … 552 562 } 553 563 } 554 555 if (c != null) {556 commandList.add(new ChangeCommand(r.getDataSet(), r, c));557 }558 564 } 559 565 changedWay.setNodes(null); // see #19885 … … 575 581 warningTypes = warnings; 576 582 this.numberOfRelations = numberOfRelations; 583 } 584 585 /** 586 * Unlink temporary copies of relations. See #19885 587 */ 588 void cleanup() { 589 for (RelationAnalysis ra : relationAnalyses) { 590 if (ra.relation.getDataSet() == null) 591 ra.relation.setMembers(null); 592 } 577 593 } 578 594 … … 688 704 } 689 705 706 Set<Relation> modifiedRelations = new LinkedHashSet<>(); 690 707 // Perform the split. 691 708 for (RelationAnalysis relationAnalysis : analysis.getRelationAnalyses()) { … … 729 746 } 730 747 } 748 modifiedRelations.add(relation); 749 } 750 for (Relation r : modifiedRelations) { 751 DataSet ds = way.getDataSet(); 752 Relation orig = (Relation) ds.getPrimitiveById(r); 753 analysis.getCommands().add(new ChangeMembersCommand(orig, new ArrayList<>(r.getMembers()))); 754 r.setMembers(null); // see #19885 731 755 } 732 756
Note:
See TracChangeset
for help on using the changeset viewer.