Changeset 18433 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/IRelationEditorActionAccess.java
r18413 r18433 75 75 default IRelation<?> getChangedRelation() { 76 76 final Relation newRelation; 77 if (getEditor().getRelation() != null) { 78 newRelation = new Relation(getEditor().getRelation()); 77 final Relation oldRelation = getEditor().getRelation(); 78 if (oldRelation != null && oldRelation.getDataSet() != null && oldRelation.getDataSet().isLocked()) { 79 // If the dataset is locked, then we cannot change the relation. See JOSM #22024. 80 // This is due to the `setMembers` -> `addReferrer` call chain requires that the dataset is not read only. 81 return oldRelation; 82 } else if (oldRelation != null) { 83 newRelation = new Relation(oldRelation); 79 84 } else { 80 85 newRelation = new Relation(); -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/actions/RelationEditorActionsTest.java
r17275 r18433 2 2 package org.openstreetmap.josm.gui.dialogs.relation.actions; 3 3 4 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 4 5 import static org.junit.jupiter.api.Assertions.assertEquals; 5 6 import static org.junit.jupiter.api.Assertions.assertTrue; … … 14 15 import org.junit.jupiter.api.Test; 15 16 import org.openstreetmap.josm.TestUtils; 17 import org.openstreetmap.josm.data.coor.LatLon; 18 import org.openstreetmap.josm.data.osm.DataSet; 19 import org.openstreetmap.josm.data.osm.Node; 20 import org.openstreetmap.josm.data.osm.Relation; 21 import org.openstreetmap.josm.data.osm.RelationMember; 16 22 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; 23 import org.openstreetmap.josm.gui.MainApplication; 24 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 17 25 import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; 18 26 … … 142 150 assertTrue(jopMockerCalled[0]); 143 151 } 152 153 /** 154 * Non-regression test for JOSM #22024. 155 * This is due to a race condition between uploading and refreshing the relation in the editor. 156 */ 157 @Test 158 void testNonRegression22024() { 159 final DataSet ds = new DataSet(); 160 final Node node = new Node(LatLon.ZERO); 161 Relation relation = TestUtils.newRelation("type=restriction", new RelationMember("", node)); 162 ds.addPrimitive(node); 163 ds.addPrimitive(relation); 164 MainApplication.getLayerManager().prepareLayerForUpload(new OsmDataLayer(ds, "testNonRegression22024", null)); 165 // Sanity check that behavior hasn't changed 166 assertTrue(ds.isLocked(), "The dataset should be locked when it is being uploaded."); 167 relationEditorAccess.getEditor().setRelation(relation); 168 relationEditorAccess.getMemberTableModel().populate(relation); 169 relationEditorAccess.getTagModel().initFromPrimitive(relation); 170 relationEditorAccess.getEditor().reloadDataFromRelation(); 171 assertDoesNotThrow(relationEditorAccess::getChangedRelation); 172 } 144 173 }
Note:
See TracChangeset
for help on using the changeset viewer.