Changeset 3782 in josm for trunk/src/org
- Timestamp:
- 2011-01-09T18:19:37+01:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r3588 r3782 74 74 * Note that it is not necessary to call beginUpdate/endUpdate for every dataset modification - dataset will get locked 75 75 * automatically. 76 * 77 * Note that locks cannot be upgraded - if one threads use read lock and and then write lock, dead lock will occur - see #5814 for 78 * sample ticket 76 79 * 77 80 * @author imi -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r3754 r3782 173 173 // the data. 174 174 DataSet ds = null; 175 // The popup != null check is required because a left-click 176 // produces several events as well, which would make this 177 // variable true. Of course we only want the popup to show 178 // if the middle mouse button has been pressed in the first 179 // place 180 boolean isAtOldPosition = (oldMousePos != null 181 && oldMousePos.equals(ms.mousePos) 182 && popup != null); 183 boolean middleMouseDown = (ms.modifiers & MouseEvent.BUTTON2_DOWN_MASK) != 0; 175 184 try { 176 185 ds = mv.getCurrentDataSet(); 177 186 if (ds != null) { 178 187 // This is not perfect, if current dataset was changed during execution, the lock would be useless 179 ds.getReadLock().lock(); 188 if(isAtOldPosition && middleMouseDown) { 189 // Write lock is necessary when selecting in popupCycleSelection 190 // locks can not be upgraded -> if do read lock here and write lock later (in OsmPrimitive.updateFlags) 191 // then always occurs deadlock (#5814) 192 ds.beginUpdate(); 193 } else { 194 ds.getReadLock().lock(); 195 } 180 196 } 181 197 … … 183 199 statusBarElementUpdate(ms); 184 200 185 // The popup != null check is required because a left-click186 // produces several events as well, which would make this187 // variable true. Of course we only want the popup to show188 // if the middle mouse button has been pressed in the first189 // place190 boolean isAtOldPosition = (oldMousePos != null191 && oldMousePos.equals(ms.mousePos)192 && popup != null);193 boolean middleMouseDown = (ms.modifiers & MouseEvent.BUTTON2_DOWN_MASK) != 0;194 201 195 202 // Popup Information … … 247 254 } finally { 248 255 if (ds != null) { 249 ds.getReadLock().unlock(); 256 if(isAtOldPosition && middleMouseDown) { 257 ds.endUpdate(); 258 } else { 259 ds.getReadLock().unlock(); 260 } 250 261 } 251 262 }
Note:
See TracChangeset
for help on using the changeset viewer.