<AWT Dev> <AWT dev> Review Request for 8006941 : [macosx] Deadlock in drag and drop & 7199783 : Setting cursor on DragSourceContext does not work on OSX

Petr Pchelko petr.pchelko at oracle.com
Wed Feb 27 05:43:54 PST 2013

Hello, AWT Team.

Please, review the fix for 2 issues:
http://bugs.sun.com/view_bug.do?bug_id=7199783  Setting cursor on DragSourceContext does not work on OSX 
http://bugs.sun.com/view_bug.do?bug_id=8006941  Deadlock in drag and drop
The fix is available at:

I have made a single fix for these 2 issues, because they are quite closely related, and the same methods need to be changed. And they depend on one another quite a bit.

1. The deadlock occurred because in CDragSourceContextPeer.dragMouseMoved methods on components were invoke on the Appkit thread. They blocked on an AWTTreeLock if EDT had already took it. EDT trying to perform a sync selector on the Appkit thread lead to a deadlock. So the logic of working with components are moved to the EDT now.
2. DragSource events were dispatched absolutely incorrectly. Now we dispatch them the same way as on other platforms. 
3. CCursorManager contained a workaround for the issue that we were not able to perform sync selectors during the dnd. Now sync selectors are processed during drag, so this workaround is not needed any more.
4. The functionality to set a cursor in DragSourceListeners is implemented. It works, however it still has a couple of issues:
	a. Sometimes mouse events are dispatched during the dnd, which might reset a cursor. That is wrong, mouse events should not be dispatched. It is a separate issue, so this problem will disappear as mouseEvent dispatching would be fixed.
	b. If the DropTarget supports NSDragOperationCopy cocoa sets an NSDragCopyCursor. There is no API to disable this and I have found no suitable workaround.
	c. On the first drag in the lifetime of the application cursor is not set. This is due to a bug in cocoa. They reset a cursor in some setter which looks absolutely unrelated and called when the first dragging session is initialized. I am thinking about filing a bug against apple.
5. Some cleanup: removed unused variables.

With best regards. Petr.

More information about the awt-dev mailing list