Repository navigation
Fix Paste button deadlock in ribbon - #272
Merged
Merged
Conversation
Member
|
Merged — thank you for the contribution! If you haven't already, come join us on the ArtCraft Discord: https://discord.gg/artcraft |
This was referenced Oct 12, 2026
neilcawse
added a commit
to neilcawse/gridcraft
that referenced
this pull request
Oct 13, 2026
…ion test (storytold#273) In 0.5.0 a click anywhere on the Home ribbon's Paste button (label, icon or dropdown arrow) froze the app for good. home() called paste.secondary_clicked() inside ctx.data_mut(); after any click egui answers that with ctx.input(), which takes the context lock the closure already holds, so the UI thread waited on itself. Sampling the hung 0.5.0 process on macOS shows the main thread parked in RawRwLock::lock_exclusive_slow under Context::write <- data_mut <- ribbon::home. storytold#272 moved the query out of the closure; it landed after the 0.5.0 release, which is the build both reporters used. No test ever clicked the Paste button itself, which is how this shipped. The new test clicks it, then opens its menu with a secondary click and picks Paste Values, on a worker thread with a timeout so a regression fails instead of hanging the run. With storytold#272 reverted it fails (egui's debug lock check panics after 10 s); with it, it passes. The Paste button gets an accessible "Paste" name so the test (and screen readers) can find it, the same way Pictures and Border presets are named. With the freeze gone, the button still did not do what it says: it pasted GridCraft's own copy only (GridState::system_clipboard was never assigned), so text copied in another app gave "Nothing to paste." The ribbon button, its options menu's Paste, the cell and header context menus and the macOS Edit menu now read the system clipboard through a new paste_text host service and paste it like Cmd/Ctrl+V does, falling back to GridCraft's own copy when there is no text (or no service, as on the web). Asking egui for the clipboard instead (RequestPaste) was tried and stalled the macOS event loop until the next input event. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fix GridCraft freezing when clicking Paste.
Root cause: paste.secondary_clicked() was called inside an egui Context::data_mut() closure, causing nested context locking.
Fix: Evaluate secondary_clicked() before acquiring the write lock.
Testing: Reproduced the freeze, captured the deadlock using GDB, and confirmed the fix works on Debian 13 KDE Plasma (Wayland), GridCraft 0.4.0.
Tested on Debian only. Windows, macOS, and other Linux distributions remain untested.
Changes only crates/ui-egui/src/ribbon.rs. Independent of PR #260 and PR #268.