Changeset 5653 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2012-12-31T14:41:24+01:00 (11 years ago)
Author:
Don-vip
Message:

Fix #8128 - NPE while dragging object

File:
1 edited

Legend:

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

    r5447 r5653  
    674674        Command c = getLastCommand();
    675675        if (mode == Mode.move) {
     676            if (startEN == null) return false; // fix #8128
    676677            getCurrentDataSet().beginUpdate();
    677678            if (c instanceof MoveCommand && affectedNodes.equals(((MoveCommand) c).getParticipatingPrimitives())) {
     
    686687                    // Revert move
    687688                    ((MoveCommand) c).resetToCheckpoint();
     689                    getCurrentDataSet().endUpdate();
    688690                    JOptionPane.showMessageDialog(
    689691                            Main.parent,
     
    695697                }
    696698            }
    697             getCurrentDataSet().endUpdate();
    698             return true;
    699         }
    700 
    701         startEN = currentEN; // drag can continue after scaling/rotation
    702 
    703         if (mode == Mode.rotate) {
    704             getCurrentDataSet().beginUpdate();
    705             if (c instanceof RotateCommand && affectedNodes.equals(((RotateCommand) c).getTransformedNodes())) {
    706                 ((RotateCommand) c).handleEvent(currentEN);
     699        } else {
     700            startEN = currentEN; // drag can continue after scaling/rotation
     701   
     702            if (mode == Mode.rotate) {
     703                getCurrentDataSet().beginUpdate();
     704                if (c instanceof RotateCommand && affectedNodes.equals(((RotateCommand) c).getTransformedNodes())) {
     705                    ((RotateCommand) c).handleEvent(currentEN);
     706                } else {
     707                    Main.main.undoRedo.add(new RotateCommand(selection, currentEN));
     708                }
     709            } else if (mode == Mode.scale) {
     710                getCurrentDataSet().beginUpdate();
     711                if (c instanceof ScaleCommand && affectedNodes.equals(((ScaleCommand) c).getTransformedNodes())) {
     712                    ((ScaleCommand) c).handleEvent(currentEN);
     713                } else {
     714                    Main.main.undoRedo.add(new ScaleCommand(selection, currentEN));
     715                }
    707716            } else {
    708                 Main.main.undoRedo.add(new RotateCommand(selection, currentEN));
    709             }
    710             getCurrentDataSet().endUpdate();
    711         } else if (mode == Mode.scale) {
    712             getCurrentDataSet().beginUpdate();
    713             if (c instanceof ScaleCommand && affectedNodes.equals(((ScaleCommand) c).getTransformedNodes())) {
    714                 ((ScaleCommand) c).handleEvent(currentEN);
    715             } else {
    716                 Main.main.undoRedo.add(new ScaleCommand(selection, currentEN));
    717             }
    718             getCurrentDataSet().endUpdate();
    719         }
     717                return false;
     718            }
     719        }
     720        getCurrentDataSet().endUpdate();
    720721        return true;
    721722    }
Note: See TracChangeset for help on using the changeset viewer.