Changeset 17362 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2020-11-26T16:39:04+01:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r17188 r17362 223 223 setHighlightedWaySegments(Collections.emptyList()); 224 224 DISPLAY_COUNT.decrementAndGet(); 225 if (getValue() != 1) { 226 newWays.forEach(w -> w.setNodes(null)); // see 19885 227 } 225 228 } 226 229 } … … 304 307 } 305 308 }); 309 if (!splitWayCommand.isPresent()) { 310 newWays.forEach(w -> w.setNodes(null)); // see 19885 311 } 306 312 } 307 313 -
trunk/src/org/openstreetmap/josm/command/SplitWayCommand.java
r17359 r17362 24 24 import java.util.Set; 25 25 import java.util.function.Consumer; 26 import java.util.stream.Collectors; 26 27 27 28 import javax.swing.JOptionPane; … … 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, … … 396 397 } 397 398 398 switch (missingMemberStrategy) { 399 try { 400 switch (missingMemberStrategy) { 399 401 case GO_AHEAD_WITH_DOWNLOADS: 400 402 try { … … 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 return Optional.of(splitBasedOnAnalyses(way, newWays, newSelection, analysis, indexOfWayToKeep)); 423 } finally { 424 // see #19885 425 wayToKeep.setNodes(null); 426 analysis.cleanup(); 418 427 } 419 428 } … … 443 452 } 444 453 445 numberOfRelations++;454 boolean isSimpleCase = true; 446 455 447 456 Relation c = null; … … 549 558 } 550 559 relationAnalyses.add(new RelationAnalysis(c, rm, direction, missingWays)); 560 isSimpleCase = false; 551 561 } 552 562 } 553 563 } 554 555 if (c != null) { 556 commandList.add(new ChangeCommand(r.getDataSet(), r, c)); 564 if (!isSimpleCase) 565 numberOfRelations++; 566 if (c != null && isSimpleCase) { 567 if (!r.getMembers().equals(c.getMembers())) { 568 commandList.add(new ChangeMembersCommand(r, new ArrayList<>(c.getMembers()))); 569 numberOfRelations++; 570 } 571 c.setMembers(null); // see #19885 557 572 } 558 573 } … … 575 590 warningTypes = warnings; 576 591 this.numberOfRelations = numberOfRelations; 592 } 593 594 /** 595 * Unlink temporary copies of relations. See #19885 596 */ 597 void cleanup() { 598 for (RelationAnalysis ra : relationAnalyses) { 599 if (ra.relation.getDataSet() == null) 600 ra.relation.setMembers(null); 601 } 577 602 } 578 603 … … 729 754 } 730 755 } 756 } 757 758 // add one command for each complex case with relations 759 final DataSet ds = way.getDataSet(); 760 for (Relation r : analysis.getRelationAnalyses().stream().map(RelationAnalysis::getRelation).collect(Collectors.toSet())) { 761 Relation orig = (Relation) ds.getPrimitiveById(r); 762 analysis.getCommands().add(new ChangeMembersCommand(orig, new ArrayList<>(r.getMembers()))); 763 r.setMembers(null); // see #19885 731 764 } 732 765
Note:
See TracChangeset
for help on using the changeset viewer.