Changeset 17172 in josm


Ignore:
Timestamp:
2020-10-12T15:12:32+02:00 (2 weeks ago)
Author:
GerdP
Message:

see #19913: IOOBE: Index 254 out of bounds for length 0: Saving a relation, after splitting a child member with open relation editor
see #19915: Crash in relation editor when saving after undo

  • enable Refresh button when snapshot is different to data in layer
  • enable Apply button also when relation was removed by undoing the creation of it
  • move some dispose() code from RelationEditor to GenericRelationEditor
Location:
trunk/src/org/openstreetmap/josm/gui/dialogs/relation
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java

    r17140 r17172  
    5151import org.openstreetmap.josm.command.ChangeCommand;
    5252import org.openstreetmap.josm.command.Command;
     53import org.openstreetmap.josm.data.UndoRedoHandler;
     54import org.openstreetmap.josm.data.UndoRedoHandler.CommandQueueListener;
    5355import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
    5456import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    115117 * @since 343
    116118 */
    117 public class GenericRelationEditor extends RelationEditor {
     119public class GenericRelationEditor extends RelationEditor implements CommandQueueListener {
    118120    /** the tag table and its model */
    119121    private final TagEditorPanel tagEditorPanel;
     
    310312        memberTableModel.setSelectedMembers(selectedMembers);
    311313        HelpUtil.setHelpContext(getRootPane(), ht("/Dialog/RelationEditor"));
     314        UndoRedoHandler.getInstance().addCommandQueueListener(this);
    312315    }
    313316
     
    836839    public void dispose() {
    837840        refreshAction.destroy();
     841        UndoRedoHandler.getInstance().removeCommandQueueListener(this);
     842        setRelation(null);
    838843        super.dispose();
    839844    }
     
    10151020
    10161021    }
     1022
     1023    @Override
     1024    public void commandChanged(int queueSize, int redoSize) {
     1025        Relation r = getRelation();
     1026        if (r != null && r.getDataSet() == null) {
     1027            // see #19915
     1028            setRelation(null);
     1029            applyAction.updateEnabledState();
     1030        }
     1031    }
    10171032}
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationEditor.java

    r17140 r17172  
    158158    public void dispose() {
    159159        layer.setRecentRelation(relation);
    160         setRelation(null);
    161160        super.dispose();
    162161    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/ApplyAction.java

    r14030 r17172  
    3535
    3636    @Override
    37     protected void updateEnabledState() {
     37    public void updateEnabledState() {
    3838        setEnabled(isEditorDirty());
    3939    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/RefreshAction.java

    r17063 r17172  
    6868    @Override
    6969    public void updateEnabledState() {
    70         Relation snapshot = editorAccess.getEditor().getRelationSnapshot();
    71         setEnabled((!getMemberTableModel().hasSameMembersAs(snapshot) || getTagModel().isDirty())
    72                 && !(snapshot == null && getTagModel().getTags().isEmpty()));
     70        Relation snapshot = getEditor().getRelationSnapshot();
     71        Relation relation = getEditor().getRelation();
     72        if (relation != null && relation.getDataSet() == null)
     73            relation = null; // see #19915
     74        if (relation != null && snapshot != null && snapshot.getDataSet() == null) {
     75            // relation was changed outside of the editor
     76            // either it was modified or deleted or changed by an undo
     77            setEnabled(!snapshot.hasEqualSemanticAttributes(relation));
     78            return;
     79        }
     80        setEnabled(false);
    7381    }
    7482
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/SavingAction.java

    r17171 r17172  
    178178    protected boolean isEditorDirty() {
    179179        Relation snapshot = editorAccess.getEditor().getRelationSnapshot();
    180         return (snapshot != null && !getMemberTableModel().hasSameMembersAs(snapshot)) || getTagModel().isDirty();
     180        return (snapshot != null && !getMemberTableModel().hasSameMembersAs(snapshot)) || getTagModel().isDirty()
     181                || getEditor().getRelation() == null || getEditor().getRelation().getDataSet() == null;
    181182    }
    182183}
Note: See TracChangeset for help on using the changeset viewer.