Repository navigation
DragSource: make a new drag context for each drag - #69
Merged
guillerodriguez merged 1 commit intoOct 28, 2026
Merged
Conversation
This was referenced Oct 14, 2026
duncanmcqueen
marked this pull request as ready for review
October 14, 2026 23:52
duncanmcqueen
force-pushed
the
fix-dragsource-context
branch
from
October 15, 2026 13:51
b6c41fa to
12de7e1
Compare
guillerodriguez
requested changes
Oct 20, 2026
startDrag() made the drag source context peer and the context only when its fields were null, so every later drag reused the context of the first drag, with its trigger event and its Transferable. Make a new peer and a new context for each drag. Nothing else uses them, so they are now local variables. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: duncanmcqueen <dwmcqueen@gmail.com>
duncanmcqueen
force-pushed
the
fix-dragsource-context
branch
from
October 22, 2026 13:25
12de7e1 to
de89723
Compare
Contributor
Author
|
Thank you. I agree. I ran the test again on Haiku with JamVM. It passes. I added the result to the description. |
guillerodriguez
approved these changes
Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split from #57.
Problem and fix
DragSource.startDrag()makes the drag source context peer and theDragSourceContextonly when its fields arenull. Thus the second and all later drags use the peer and the context of the first drag, with the trigger event and theTransferableof the first drag. The user drags the data of the first drag again.Now
startDrag()makes a new peer and a new context for each drag. Nothing else uses them, so they are now local variables, not fields. I found this bug when I wrote an AWT toolkit for Haiku, which supplies drag and drop peers.How to reproduce
The GTK peer starts a native drag, so the test uses a toolkit that replaces only
createDragSourceContextPeer(). Its peer records theTransferableof each drag. The toolkit class must be on the boot class path, becauseToolkitloads it with the boot class loader. The test needs a display, because the toolkit extendsGtkToolkit.javac DragSourceNewContext.java java -Xbootclasspath/a:. -Dawt.toolkit='DragSourceNewContext$TestToolkit' DragSourceNewContextDragSourceNewContext.javaResults
Linux x86_64, ingelabs/classpath
master(0406074), JamVMmaster,javacfrom JDK 8, autoconf 2.73, automake 1.19, theconfigureoptions of the CI Linux job, out-of-tree build. "Before" ismaster. "After" ismasterwith this commit.I also ran the test again with this version on Haiku R1/beta6 x86_64 (hrev60228), JamVM with the Haiku port (#25 in ingelabs/jamvm), and ingelabs/classpath built on Haiku. I compiled each version of the changed classes with
javacfrom OpenJDK 8 and put them first on the boot class path (-Xbootclasspath/p). The test toolkit extendedgnu.java.awt.peer.haiku.HaikuToolkitinstead ofGtkToolkit.Platforms
Not specific to Haiku. The problem is in
java.awt.dnd.DragSourceand occurs with all toolkits. I reproduced it on Linux.AI assistance
An AI model (Claude Code, by Anthropic) wrote this change, the test and this text. The repository owner directed the work and checked the results. Please review it as you review other contributions.
🤖 Generated with Claude Code