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

Bug 312365

Summary: Carbon: DnD fails when dropping object to a child control.
Product: [Eclipse Project] Platform Reporter: Hiroyuki Okamoto <hokamoto>
Component: SWTAssignee: Silenio Quarti <Silenio_Quarti>
Status: RESOLVED FIXED QA Contact: Silenio Quarti <Silenio_Quarti>
Severity: normal    
Priority: P3 CC: hokamoto, mukund, raji, robin.howlett, Silenio_Quarti
Version: 3.5   
Target Milestone: 3.6.1   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Snippet to reproduce this issue.
none
proposed patch
none
fix none

Description Hiroyuki Okamoto CLA 2010-05-10 22:13:48 EDT
Build Identifier: SWT v3646a

DnD fails when dropping object to a child control.
So far, we see this issue on Carbon/Mac OS X. Windows works.

Reproducible: Always

Steps to Reproduce:
1. Create a Composite and setup DropTarget for it.
2. Create a child control in the Composite.
3. Drop an object to the child control.

result: 
the dropped object ignored, and DnD fails.

problem:
The bug is in DropTarget.FindDropTarget().
The bug happens because DropTarget.FindDropTarget() thinks the DnD object dropped to the child control, But, since the child control's getData() returns null, the line "return (DropTarget) widget.getData(DND.DROP_TARGET_KEY);" returns null. It should return correct parent in this case.
Comment 1 Hiroyuki Okamoto CLA 2010-05-10 22:18:03 EDT
Created attachment 167857 [details]
Snippet to reproduce this issue.

Steps to reproduce:
1. Run the snippet - X.java
2. Drag the left label
3. Drop to the right Text control.
4. DropTarget.FindDropTarget() returns null, and fails to drop the obj. (that's the bug.)

Thanks,
Hiro
Comment 2 Hiroyuki Okamoto CLA 2010-05-10 22:18:50 EDT
Created attachment 167858 [details]
proposed patch

Please review this proposed patch.

Thanks,
Hiro
Comment 3 Raji Akella CLA 2010-05-11 11:31:03 EDT
Silenio, can you give us your input on the proposed patch?
Comment 4 Hiroyuki Okamoto CLA 2010-05-14 11:25:01 EDT
Silenio,
could you review the proposed patch at least ?  
Our product needs to fix this issue asap. so if the patch looks ok, our product is going to merge it in our swt asap.

Thanks,
Hiro
Comment 5 Silenio Quarti CLA 2010-05-14 11:59:25 EDT
Created attachment 168556 [details]
fix

Sorry about the delay. We are quite busy with the 3.6 end game.

This should be the fix. Same idea, but it uses OS calls to get parent instead of Control.getParent().
Comment 6 Raji Akella CLA 2010-05-14 12:23:58 EDT
Thanks Silenio.
Comment 7 Hiroyuki Okamoto CLA 2010-05-14 13:46:24 EDT
Thank you Silenio!
We will test the fix with our product and let you know the result.

Thanks,
Hiro
Comment 8 Hiroyuki Okamoto CLA 2010-05-14 13:52:24 EDT
We verified the fix works with our product.  Thanks!
Comment 9 Raji Akella CLA 2010-08-05 19:31:50 EDT
Silenio, can you include this in 3.6.1?
Comment 10 Silenio Quarti CLA 2010-08-06 12:02:59 EDT
Fix has been release to R3_6_maintenance and HEAD.