Opened 3 years ago
Closed 3 years ago
#21813 closed enhancement (fixed)
[Patch] Improve marker handling in sessions
Reported by: | Bjoeni | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | 22.06 |
Component: | Core | Version: | tested |
Keywords: | gpx marker extension session | Cc: |
Description
When opening a *.gpx file containing both GPX tracks and markers two layers are opened. When saving that to a session the markers will essentially be saved twice: Once in the original GPX file (either included in the *.joz or seperately) and once in the marker file included in the *.joz.
That is redundant and can lead to complications since the two layers are no longer associated to each other after being loaded from a session file.
(e.g. when changing the settings of the markers, that would not be reflected when exporting the original GPX file again since it's no longer associated)
I'm planning on not exporting a marker layer to a session file at all when it's already included the GPX file. Markers should only be included when the corresponding GPX track does not exist anymore (i.e. is not loaded as a layer). That also allows saving as *.jos in these cases (see #20913).
This also requires some changes when loading the session since currently all waypoints in GPX files from sessions are simply ignored.
Attachments (3)
Change History (16)
comment:1 by , 3 years ago
Milestone: | → 22.03 |
---|---|
Owner: | changed from | to
Status: | assigned → new |
Summary: | Improve marker handling in sessions → [Patch] Improve marker handling in sessions |
- markers that are linked to a GPX layer will be saved as a "sub layer" of the GPX layer (and only saved once)
by , 3 years ago
Attachment: | 21813.patch added |
---|
comment:2 by , 3 years ago
comment:3 by , 3 years ago
Milestone: | 22.03 → 22.04 |
---|
comment:5 by , 3 years ago
I got a crash while testing this patch:
2022-05-18 13:03:40.963 java[12872:11492749] 2022-05-18 13:03:40.960 SEVERE: Handled by bug report queue: java.lang.NullPointerException java.lang.NullPointerException at java.desktop/java.awt.Container.addImpl(Container.java:1117) at java.desktop/java.awt.Container.add(Container.java:997) at org.openstreetmap.josm.actions.SessionSaveAsAction$SessionSaveAsDialog.build(SessionSaveAsAction.java:299) at org.openstreetmap.josm.actions.SessionSaveAsAction$SessionSaveAsDialog.<init>(SessionSaveAsAction.java:235) at org.openstreetmap.josm.actions.SessionSaveAsAction.saveSession(SessionSaveAsAction.java:113) at org.openstreetmap.josm.actions.SessionSaveAsAction.actionPerformed(SessionSaveAsAction.java:91) at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967) at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308) at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405) at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262) at java.desktop/javax.swing.AbstractButton.doClick(AbstractButton.java:369) at java.desktop/com.apple.laf.ScreenMenuItem.actionPerformed(ScreenMenuItem.java:129) at java.desktop/java.awt.MenuItem.processActionEvent(MenuItem.java:690) at java.desktop/java.awt.MenuItem.processEvent(MenuItem.java:649) at java.desktop/java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:375) at java.desktop/java.awt.MenuComponent.dispatchEvent(MenuComponent.java:363) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:775) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Steps to reproduce:
- Load the
test/data/sessions/markers.gpx
file into JOSM (easy way:java -jar dist/josm-custom.jar test/data/sessions/markers.gpx
) - Attempt to save the session
comment:6 by , 3 years ago
follow-up: 9 comment:7 by , 3 years ago
comment:8 by , 3 years ago
Milestone: | 22.05 → 22.06 |
---|
comment:9 by , 3 years ago
Replying to taylor.smock:
The reason why I merged #19219 and #21922 separately was because they were small and fairly easy for me to test. Larger patches typically require more testing, more analysis, etc. And I'm also less likely to merge them near a potential release.
Sure, I didn't mean to criticize that. That was merely a note to myself, I'll probably just not provide potentially conflicting patches at the same time in the future. Either an all in one patch or I'll just wait until the previous one has been committed.
Either way, here's a combined and updated patch for this ticket and #21923, now it should work:
by , 3 years ago
Attachment: | 21813-21923-v2.patch added |
---|
follow-up: 11 comment:10 by , 3 years ago
Thank you for the updated patch. I'll take a look at it next week. If I haven't gotten back to you by next Tuesday, ping me.
A few quick comments (from a read through):
- In SessionSaveAction#getTooltip, why didn't you use
getInstance().getToolTipText()
? - The LayerManager diff seems a bit large. This is probably due to line endings. It is an unrelated change, but something that is overall "good".
- SessionWriterTest.java L167 (
/**R
->/**\n * R
) - I'd like to have
@since xxx
for the newly public methods in the test classes, but we don't version thejosm-unittest.jar
file, so not currently useful (this can make tests for plugins fail when JOSM changes its signing key).
follow-up: 12 comment:11 by , 3 years ago
Replying to taylor.smock:
Thank you for the updated patch. I'll take a look at it next week. If I haven't gotten back to you by next Tuesday, ping me.
A few quick comments (from a read through):
- In SessionSaveAction#getTooltip, why didn't you use
getInstance().getToolTipText()
?
Because the class inherits JosmAction
which doesn't have that method and doesn't keep the tooltip that was set. It only keeps the dynamically generated tooltip with the shortcut (including HTML formatting).
- The LayerManager diff seems a bit large. This is probably due to line endings.
Yeah don't know what happened there. Changed.
It is an unrelated change, but something that is overall "good".
Do you mean the line endings or the change to isEmpty()
? If the latter then no, it's not unrelated because I rely on that event in SessionSaveAction#layerRemoving()
. And it simply didn't work before because it checked if there was one layer left after removing the layer. It just wasn't used anywhere in the project and therefore probably never noticed.
- SessionWriterTest.java L167 (
/**R
->/**\n * R
)
changed.
- I'd like to have
@since xxx
for the newly public methods in the test classes, but we don't version thejosm-unittest.jar
file, so not currently useful (this can make tests for plugins fail when JOSM changes its signing key).
Added. Thanks for the feedback.
I updated the patch. Also the LayerChangeListener
will now be properly removed.
by , 3 years ago
Attachment: | 21813-21923-v2.1.patch added |
---|
comment:12 by , 3 years ago
Replying to Bjoeni:
Replying to taylor.smock:
It is an unrelated change, but something that is overall "good".
Do you mean the line endings or the change to
isEmpty()
? If the latter then no, it's not unrelated because I rely on that event inSessionSaveAction#layerRemoving()
. And it simply didn't work before because it checked if there was one layer left after removing the layer. It just wasn't used anywhere in the project and therefore probably never noticed.
That makes me wonder why it was size() == 1
. (When I was skimming the patch, I read it as size() == 0
).
So I looked at history: size() == 1
was added in r10432. It looks like r10273 had the removal occur after the event fire, and r10998 changed that (removal occurred before event fire), and due to a lack of tests, it wasn't noticed that the behavior was different for lastLayer
.
[...] Thanks for the feedback.
You are welcome.