Skip to content

Commit

Permalink
Bugfix: fixed crash when non-ways where selected
Browse files Browse the repository at this point in the history
  • Loading branch information
tibnor committed Jun 7, 2015
1 parent 27f8c5f commit 5200b6d
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void actionPerformed(ActionEvent e) {

// There must be two ways selected: one with id > 0 and one new.
List<OsmPrimitive> selection = new ArrayList<>(getCurrentDataSet().getSelected());
if (selection.size() != 2 && selection.get(0) instanceof Way && selection.get(1) instanceof Way) {
if (selection.size() != 2 || !(selection.get(0) instanceof Way && selection.get(1) instanceof Way)) {
new Notification(
tr("This tool replaces coastline of one way with another, and so requires exactly two coatline ways to be selected.")
).setIcon(JOptionPane.WARNING_MESSAGE).show();
Expand Down Expand Up @@ -115,7 +115,16 @@ protected void updateEnabledState() {

@Override
protected void updateEnabledState( Collection<? extends OsmPrimitive> selection ) {
setEnabled(selection != null && selection.size() >= 2 );
boolean allWays = true;
for (OsmPrimitive w : selection) {
if( !(w instanceof Way)){
allWays = false;
break;
}

}

setEnabled(selection != null && selection.size() == 2 && allWays);
}
}

0 comments on commit 5200b6d

Please sign in to comment.