Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 140384

Summary: [DND] error adding children widget during drop callback
Product: [Eclipse Project] Platform Reporter: Felipe Heidrich <eclipse.felipe>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED WONTFIX QA Contact: Kevin Barnes <cocoakevin>
Severity: normal    
Priority: P3 CC: duongn, snorthov, veronika_irvine
Version: 3.1Keywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description Felipe Heidrich CLA 2006-05-05 11:47:09 EDT
Build id: I20060504-1600

Have a composite and add one (or more) child to it. Hook a file droptarget listener to it and add more children to the composite during the drop callback.
The error depends on the widget you add, if it is a CCombo the application will crash, other widget cause cheese.

Here the snippet:
static void addItem (Composite c, String string) {
	CCombo combo = new CCombo(c, SWT.NONE);
	combo.setItems(new String[] {"win32", "motif", "gtk", "carbon", "photon"});	
	c.layout();
}

public static void main (String [] args) {
	final Display  display = new Display ();
	Shell shell = new Shell (display);
	shell.setLayout(new FillLayout());
	final Composite c = new Composite(shell, SWT.BORDER);
	c.setLayout(new RowLayout());
	addItem (c, "initial item");
	
	display.addFilter(SWT.KeyDown, new Listener() {
		public void handleEvent(Event event) {
			if (event.keyCode == SWT.F2) {
				String[] files = {"File 0", "File 1", "File 2", "File 3", "File 4"};
				for (int i = 0; i < files.length; i++) {
					addItem (c, files[i]);
				}
			}
		}
	});
	
	int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_DEFAULT; 
	DropTarget target = new DropTarget(c, operations); 
	final FileTransfer fileTransfer = FileTransfer.getInstance(); 
	Transfer[] types = new Transfer[] {fileTransfer};
	target.setTransfer(types); 		  
	target.addDropListener(new DropTargetAdapter() {
		public void drop(DropTargetEvent event) {
			if (fileTransfer.isSupportedType(event.currentDataType)) {
				String[] files = (String[]) event.data;
				for (int i = 0; i < files.length; i++) {
					addItem (c, files[i]);
				}
			}	
		}
	});

	shell.setSize(550, 380);
	shell.open ();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep ();
		}
	}
	display.dispose ();
}
Comment 1 Felipe Heidrich CLA 2006-05-05 11:55:42 EDT
I can't reproduce this problem if, in OS.java, I comment out the line:
OS.ActivateActCtx (hActCtx, lpCookie);
Comment 2 Leo Ufimtsev CLA 2017-08-03 12:31:48 EDT
This is a one-off bulk update. (The last one in the triage migration).

Moving bugs from swt-triaged@eclipse to platform-swt-inbox@eclipse.org and adding "triaged" keyword as per new triage process:
https://wiki.eclipse.org/SWT/Devel/Triage

See Bug 518478 for details.

Tag for notification/mail filters:
@TriageBulkUpdate
Comment 3 Eclipse Genie CLA 2020-06-27 06:30:51 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.