#2953 closed defect (fixed)
[PATCH] Sorting a relation adds new members or crashes
Reported by: | R2D2_C3PO | Owned by: | Gubaer |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | Core | Version: | latest |
Keywords: | relation, sort | Cc: | Gubaer |
Description
Version: 1788
I was trying to sort relation 31508 usings JOSM's sort function.
First I had not all members downloaded and it failed with this exception:
java.lang.NullPointerException
at org.openstreetmap.josm.gui.dialogs.relation.RelationNodeMap.remove(RelationNodeMap.java:99)
at org.openstreetmap.josm.gui.dialogs.relation.GenericRelationEditor.sort(GenericRelationEditor.java:384)
at org.openstreetmap.josm.gui.dialogs.relation.GenericRelationEditor.access$700(GenericRelationEditor.java:106)
at org.openstreetmap.josm.gui.dialogs.relation.GenericRelationEditor$9.actionPerformed(GenericRelationEditor.java:333)
Of course sorting can't work when not all members are downloaded but a message telling the user about the problem would be better than an expection.
After downloading all members I tried to sort again. Each time I click the sort button the number of members increases. This should not happen. Sort has to reoder the existing members, not to add any new (even if they are duplicates).
Attachments (0)
Change History (11)
comment:1 by , 15 years ago
Summary: | Sorting a relation adds new members or crashes → [PATCH] Sorting a relation adds new members or crashes |
---|
comment:2 by , 15 years ago
Owner: | changed from | to
---|
Sorry, does no longer work. Could you update it?
Assigning to Karl.
comment:3 by , 15 years ago
Cc: | added |
---|
Development on the relation editor recently was quite pacey. I had to temporarily remove the code which displays "link" information between relation members and sorts relations members.
@cjw: could you try to get it to work again?
comment:4 by , 15 years ago
The patch I linked to in my first comment here should add sorting again, and only has one minor merge conflict (I fixed something that is now also fixed in svn). But, I made a new patch, which contains an additional change:
http://www.time4t.net/~cjw/josm/josm-relation-member-sort-20090720.patch
- generic relation editor
o add back relation member sorting, with a button at the left
o add back linkedness info, but without recursion into members that are relations (can be added later)
o split MemberTableCellRenderer into 3 classes for each column to prevent a runtime type error when moving columns in the member table
comment:5 by , 15 years ago
I applied the patch in r1822 but I've disabled the sort action. Here's how I got a NoSuchElementException:
- download http://api06.dev.openstreetmap.org/api/0.6/map?bbox=7.373542785644531,46.916972287629385,7.4219512939453125,46.93924602724242
- lauch relation editor for
relation(3 members)
- sort
Here's the exceptions stack trace:
java.util.NoSuchElementException at java.util.Vector.lastElement(Vector.java:461) at org.openstreetmap.josm.gui.dialogs.relation.MemberTableModel.sort(MemberTableModel.java:428) at org.openstreetmap.josm.gui.dialogs.relation.GenericRelationEditor$SortAction.actionPerformed(GenericRelationEditor.java:770) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236) at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:231) at java.awt.Component.processMouseEvent(Component.java:5517) at javax.swing.JComponent.processMouseEvent(JComponent.java:3135) at java.awt.Component.processEvent(Component.java:5282) at java.awt.Container.processEvent(Container.java:1966) at java.awt.Component.dispatchEventImpl(Component.java:3984) at java.awt.Container.dispatchEventImpl(Container.java:2024) at java.awt.Component.dispatchEvent(Component.java:3819) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822) at java.awt.Container.dispatchEventImpl(Container.java:2010) at java.awt.Window.dispatchEventImpl(Window.java:1791) at java.awt.Component.dispatchEvent(Component.java:3819) at java.awt.EventQueue.dispatchEvent(EventQueue.java:463) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149) at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
comment:6 by , 15 years ago
I never tested relations as members (they are currently not sorted anyway) so thanks for testing this. The patch is bigger than needed because the code in svn is reformatted while I fixed the problem on my local copy. You'll have to reformat again before you can see the real diff.
follow-up: 8 comment:7 by , 15 years ago
I suggest
- you do an
svn update
to get the current version from the JOSM snv - fix the code
- create a patch
- submit it here
It's much easier then to apply your patch. And the code will look similar to what other code in JOSM looks like (it usually uses the curly-braces-on-the-same-line convention, not the curly-braces-on-the-next-line convention).
follow-up: 9 comment:8 by , 15 years ago
Replying to Gubaer:
- you do an
svn update
to get the current version from the JOSM snv
- fix the code
- create a patch
- submit it here
No, the procedure is:
- in eclipse, choose Source -> Clean up...
- choose custom + appropriate config
- finish
comment:9 by , 15 years ago
No, the procedure is:
- in eclipse, choose Source -> Clean up...
- choose custom + appropriate config
- finish
This way you didn't pick up the changes I made to your patch when I applied it the last time. There were to many try-catch blocks for NullPointerExceptions and ClassCastExceptions. Luckily it doesn't matter, though, I was able to apply your new patch. I'll check it in soon.
Thanks for the report. The exception on incomplete elements was specifically for the first element which I fixed locally. Both this problem and the duplicated members problem are fixed with the following patch:
http://www.time4t.net/~cjw/josm/josm-relation-member-sort-20090718-fixed.patch
No message is displayed yet for incomplete members as I do not know an existing method for displaying such informational/warning messages. Since much of the sorting code was removed in svn trunk, the patch contains much more than just these fixes.