Ignore:
Timestamp:
2013-12-27T00:51:13+01:00 (6 years ago)
Author:
Don-vip
Message:

fix #9423, see #6853 - incorrect selection after hitting Alt key while adding a way (regression from r4539)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r6336 r6542  
    179179
    180180        // update selection to reflect which way being modified
    181         if (currentBaseNode != null && getCurrentDataSet() != null && !getCurrentDataSet().getSelected().isEmpty()) {
     181        DataSet currentDataSet = getCurrentDataSet();
     182        if (currentBaseNode != null && currentDataSet != null && !currentDataSet.getSelected().isEmpty()) {
    182183            Way continueFrom = getWayForNode(currentBaseNode);
    183184            if (alt && continueFrom != null && (!currentBaseNode.isSelected() || continueFrom.isSelected())) {
    184                 getCurrentDataSet().beginUpdate(); // to prevent the selection listener to screw around with the state
    185                 getCurrentDataSet().addSelected(currentBaseNode);
    186                 getCurrentDataSet().clearSelection(continueFrom);
    187                 getCurrentDataSet().endUpdate();
     185                addRemoveSelection(currentDataSet, currentBaseNode, continueFrom);
    188186                needsRepaint = true;
    189187            } else if (!alt && continueFrom != null && !continueFrom.isSelected()) {
    190                 getCurrentDataSet().addSelected(continueFrom);
     188                addRemoveSelection(currentDataSet, continueFrom, currentBaseNode);
    191189                needsRepaint = true;
    192190            }
     
    197195        }
    198196        return needsRepaint;
     197    }
     198
     199    private static void addRemoveSelection(DataSet ds, OsmPrimitive toAdd, OsmPrimitive toRemove) {
     200        ds.beginUpdate(); // to prevent the selection listener to screw around with the state
     201        ds.addSelected(toAdd);
     202        ds.clearSelection(toRemove);
     203        ds.endUpdate();
    199204    }
    200205
Note: See TracChangeset for help on using the changeset viewer.