Modify

Opened 4 years ago

Closed 6 months ago

Last modified 2 months ago

#21840 closed enhancement (fixed)

[Patch] Automatically refresh relation editor on external changes

Reported by: Woazboat Owned by: team
Priority: normal Milestone: 25.05
Component: Core Version:
Keywords: Cc: stoecker

Description

Relation data in currently open relation editor windows is automatically reloaded when the relation is modified outside of the relation editor and there are no pending changes in the editor. If the relation has already been modified in the editor by the user and there are pending changes, display a warning notification instead that a conflict resolution will be required.

https://github.com/JOSM/josm/pull/88
https://patch-diff.githubusercontent.com/raw/JOSM/josm/pull/88.patch

Attachments (0)

Change History (18)

comment:1 by Woazboat, 4 years ago

Related to #12410 #12411 #15371 #16112

Last edited 4 years ago by Woazboat (previous) (diff)

comment:2 by taylor.smock, 4 years ago

A couple of comments from my perspective (feel free to disagree):

  • I think that isDirtyRelation() should have a default implementation of isDirtyRelation(false). You could go the other way (isDirtyRelation(boolean) defaults to calling isDirtyRelation(), which is probably better from an backward-looking standpoint, but it doesn't look like any plugins in SVN/JOSM GitHub use it).
  • You need to update GenericRelationEditorTest.java with the new method, if you aren't going to add a default implementation for isDirtyRelation(boolean).
  • Tests verifying the correctness of the logic would be nice. Unless we want someone to accidentally break it in the future. For this, you'd probably want to use JOptionPaneSimpleMocker.

comment:3 by Woazboat, 4 years ago

I added the default implementation for isDirtyRelation() and updated the test. Adding a unit test for the new refresh logic would be a bit more involved and also require some refactoring of the existing code as far as I can tell.

comment:4 by stoecker, 6 months ago

Milestone: 25.05

comment:5 by stoecker, 6 months ago

Resolution: fixed
Status: newclosed

In 19398/josm:

Auto relation refresh, fix #21840 - patch by Woazboat

comment:6 by stoecker, 6 months ago

In 19402/josm:

fix boolean logic broken in r19398, see #21840

comment:7 by GerdP, 3 months ago

Cc: stoecker added

When I revert r19402 I don't see this bug. What was the reason to change the logic?

comment:8 by GerdP, 3 months ago

Sorry, I changed the wrong ticket. See #24423 for a major regression.

comment:9 by GerdP, 3 months ago

With the change in r19402 the method isDirtyRelation() returns false in far too many cases.
So far I don't see any need for this complex check. Why is field dataset relevant?
Possible patch:

  • src/org/openstreetmap/josm/gui/dialogs/relation/RelationEditor.java

     
    152152
    153153    @Override
    154154    public final boolean isDirtyRelation(boolean ignoreUninterestingTags) {
    155         if (relation == null || relation.getDataSet() == null ||
    156             relationSnapshot == null || relationSnapshot.getDataSet() == null) {
    157             return false;
    158         }
    159 
    160         return !relation.hasEqualSemanticAttributes(relationSnapshot, ignoreUninterestingTags);
     155        return relation != null && !relation.hasEqualSemanticAttributes(relationSnapshot, ignoreUninterestingTags);
    161156    }
    162157
    163158    /* ----------------------------------------------------------------------- */

comment:10 by GerdP, 3 months ago

My patch makes problems when the relation editor is really dirty. This needs more thinking.

comment:11 by GerdP, 3 months ago

Seems I didn't recognize the new Notification Relation modified outside of relation editor with pending changes. Conflict resolution required.
Up to now I could only find problem with the code in the older version r19398: if relation is null the code in isDirtyRelation() would crash. I assume that was the reason to change the logic.
I'll post the patch again in ticket #24423.

comment:12 by GerdP, 2 months ago

See #24444 for a for regression caused by my patch :(

Would it be an option to revert all changes? This automatical refresh is somehow against the basic concept of the relation editor.

comment:13 by anonymous, 2 months ago

Sure, that's an option. But it also means no progress. Rather try fixing it?

comment:14 by GerdP, 2 months ago

I didn't find a simple fix. My approach would include a new status flag in the editor window which is set to true when the user clicks on Save or OK and later (when exactly?) restored to false. This would allow to distinguish wether the last change command was added inside or outside the editor when this notification is produced.

comment:15 by stoecker, 2 months ago

Sorry. Forgot login. Last was me.

comment:16 by stoecker, 2 months ago

Go ahead. This isn't simple, so probably a solution isn't simple as well...

comment:17 by GerdP, 2 months ago

see #24444. Rather a hack than a solution.

comment:18 by GerdP, 2 months ago

I don't know what's better. My workaround in 24444.patch or a complete revert of the changes for #21840.
We have to do something before the next release because current version is always warning and tested version is corrupting data.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.