Bug 24542 - [DND] Crash when drag&drop on the Package Explorer
Summary: [DND] Crash when drag&drop on the Package Explorer
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 2.0.1   Edit
Hardware: PC Linux-Motif
: P2 critical (vote)
Target Milestone: 2.0.2   Edit
Assignee: Veronika Irvine CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-10-08 22:19 EDT by Kenji Uchida CLA
Modified: 2002-10-17 10:11 EDT (History)
3 users (show)

See Also:


Attachments
Core dump when cancelling name conflict dialog (12.10 KB, text/plain)
2002-10-09 16:28 EDT, Knut Radloff CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kenji Uchida CLA 2002-10-08 22:19:03 EDT
With eclipse 2.0.1 release on redhat 7.2, workbench crashes everytime with the
follwoing operation.

1) Create a new class file in a package.
2) Drag the .java file in the Package Explorer with Ctrl key down.
3) Drop it on the same package.
    -> The "Name Conflict" dialog pops up and the dnd cursor remains on screen.
4) Leave everything alone for a while until the dnd cursor will disappear.
(about a minite)
5) Depress the cancel button on the dialog.
    -> Workbench crashes.

The crash also occurs on the Navigator.
Comment 1 Steve Northover CLA 2002-10-09 09:07:32 EDT
This sounds like a problem in UI.  I think there is a further problem in SWT 
where when an exceptions happens in dnd at a critical time, we don't or can't 
clean up properly (a C program would have the same failure as well).

Assigning to UI but putting VI on the CC list to monitor this PR for SWT issues 
It could turn out that it's SWT that it causing the exception in dnd, not 
Ecluipse.
Comment 2 Knut Radloff CLA 2002-10-09 14:25:07 EDT
Eclipse is just hanging on my machine. Do you have a stack trace in the log?
I don't think a UI exception occurs. When I cancel the name conflict dialog 
immediately Eclipse does not hang.

Is there a limitation where a Motif drop operation has to return within a 
certain amount of time? We don't return from the drop event listener until the 
dialog has been closed. Yet, the drag icon disappears after some time.
Comment 3 Knut Radloff CLA 2002-10-09 16:28:17 EDT
When I try this in an inner Eclipse I get a  VM core dump.
This definitely looks like a SWT problem. I don't have a simple test case yet.
Comment 4 Knut Radloff CLA 2002-10-09 16:28:58 EDT
Created attachment 2143 [details]
Core dump when cancelling name conflict dialog
Comment 5 Knut Radloff CLA 2002-10-10 11:39:30 EDT
Not sure if this is also a problem in the 2.1 stream. Navigator and Packages 
view DND is currently broken, i.e., does not work at all. See bug 24593.
Comment 6 Veronika Irvine CLA 2002-10-10 13:13:29 EDT
Able to reproduce problem with a simple SWT example.
You should probably reassign this to me under swt.

import org.eclipse.swt.*;
import org.eclipse.swt.dnd.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;

public class PR24542 {
public static void main (String [] args) {
	
	Display display = Display.getDefault ();
	final Shell shell = new Shell (display);
	final Label label1 = new Label (shell, SWT.BORDER);
	label1.setText ("TEXT");
	final Label label2 = new Label (shell, SWT.BORDER);
	shell.addListener (SWT.Resize, new Listener () {
		public void handleEvent (Event e) {
			Rectangle rect = shell.getClientArea ();
			int center = rect.width / 2;
			label1.setBounds (rect.x, rect.y, center, rect.height);
			label2.setBounds (center, rect.y, center, rect.height);
		}
	});
	shell.setSize (200, 200);
	setDragDrop (label1);
	setDragDrop (label2);
	shell.open ();
	while (!shell.isDisposed ()) {
		if (!display.readAndDispatch ()) display.sleep ();
	}
	display.dispose ();
}
public static void setDragDrop (final Label label) {
	
	Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
	int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
	
	final DragSource source = new DragSource (label, operations);
	source.setTransfer(types);
	source.addDragListener (new DragSourceListener () {
		public void dragStart(DragSourceEvent event) {
			event.doit = (label.getText ().length () != 0);
		};
		public void dragSetData (DragSourceEvent event) {
			event.data = label.getText ();
		}
		public void dragFinished(DragSourceEvent event) {
			if (event.detail == DND.DROP_MOVE)
				label.setText ("");
		}
	});

	DropTarget target = new DropTarget(label, operations);
	target.setTransfer(types);
	target.addDropListener (new DropTargetAdapter() {
		public void drop(DropTargetEvent event) {
			MessageBox b = new MessageBox(label.getShell(), SWT.OK);
			b.setMessage("hello");
			b.open();
			if (event.data == null) {
				event.detail = DND.DROP_NONE;
				return;
			}
			label.setText ((String) event.data);
		}
	});
}
}
Comment 7 Knut Radloff CLA 2002-10-10 13:31:08 EDT
Also a problem in 20021009 2.0.2 build.
Comment 8 Veronika Irvine CLA 2002-10-11 11:09:06 EDT
Fixed in 2.1 > 20021011.
Motif has a timeout call SelectionTimeout (XtAppGetSelectionTimeout and 
XtAppSetSelectionTimeout) which has a default value of 5 seconds.

Just before the data transfer is requested I change this value to be infinite 
and after the drop callback returns, I change this back to the original value.

Leaving this bug report open for now while we decide what to do about 2.0.2.
Comment 9 Veronika Irvine CLA 2002-10-17 10:11:12 EDT
Fixed in 2.1 and 2.0.2.