Project: SWT
Bug 66356 DND - move reported to drag source even though cancelled
Reported: 2004-06-09 13:27:43 | Status: resolved fixed

RC1 Run the following example. The dragSource.dragFinished listener shoul dhave an event.detail of DND.DROP_NONE but instead it has an event.detail of DND.DROP_MOVE. this is bad because it means the drag source may delete data even though the operation failed: public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Button source = new Button(shell, SWT.PUSH); source.setText("Source"); DragSource dragSource = new DragSource(source, DND.DROP_MOVE); dragSource.setTransfer(new Transfer[] {TextTransfer.getInstance()}); dragSource.addDragListener(new DragSourceAdapter() { public void dragSetData(DragSourceEvent event) { event.data = "hello"; } public void dragFinished(DragSourceEvent event) { System.out.println("Move = "+(event.detail == DND.DROP_MOVE)); } }); Button dest = new Button(shell, SWT.PUSH); dest.setText("Dest"); DropTarget dropTarget = new DropTarget(dest, DND.DROP_MOVE); dropTarget.setTransfer(new Transfer[] {TextTransfer.getInstance()}); dropTarget.addDropListener(new DropTargetAdapter() { public void drop(DropTargetEvent event) { event.detail = DND.DROP_NONE; } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java