Changeset 3782 in josm


Ignore:
Timestamp:
Jan 9, 2011 6:19:37 PM (2 years ago)
Author:
jttt
Message:

Fix #5814 middleclick on way getting drawn locks josm completely

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r3588 r3782  
    7474 * Note that it is not necessary to call beginUpdate/endUpdate for every dataset modification - dataset will get locked 
    7575 * 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 
    7679 * 
    7780 * @author imi 
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r3754 r3782  
    173173                    // the data. 
    174174                    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; 
    175184                    try { 
    176185                        ds = mv.getCurrentDataSet(); 
    177186                        if (ds != null) { 
    178187                            // 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                            } 
    180196                        } 
    181197 
     
    183199                        statusBarElementUpdate(ms); 
    184200 
    185                         // The popup != null check is required because a left-click 
    186                         // produces several events as well, which would make this 
    187                         // variable true. Of course we only want the popup to show 
    188                         // if the middle mouse button has been pressed in the first 
    189                         // place 
    190                         boolean isAtOldPosition = (oldMousePos != null 
    191                                 && oldMousePos.equals(ms.mousePos) 
    192                                 && popup != null); 
    193                         boolean middleMouseDown = (ms.modifiers & MouseEvent.BUTTON2_DOWN_MASK) != 0; 
    194201 
    195202                        // Popup Information 
     
    247254                    } finally { 
    248255                        if (ds != null) { 
    249                             ds.getReadLock().unlock(); 
     256                            if(isAtOldPosition && middleMouseDown) { 
     257                                ds.endUpdate(); 
     258                            } else { 
     259                                ds.getReadLock().unlock(); 
     260                            } 
    250261                        } 
    251262                    } 
Note: See TracChangeset for help on using the changeset viewer.