-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Make Clipboard::new unsafe #7826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Make Clipboard::new unsafe #7826
Conversation
|
Preview available at https://egui-pr-preview.github.io/pr/7826-fix-clipboard-new-safety View snapshot changes at kitdiff |
|
Would it make sense to have two variants of Not sure how much of this is propagated up though or if it is just simpler to mark even the |
|
I'm not sure that's such a good idea. Maybe we could keep new safe and only enable it when smithay clipboard is disabled and then have an unsafe from_raw_handle method or something like that. |
|
But it's breaking change either way. |
|
Thanks! |
|
Forgot to mention: This also probably closes #7660. |
The smithay-clipboard Clipboard::new method requires the display pointer to remain valid for the lifetime of the Clipboard. Since egui-winit's Clipboard::new cannot guarantee this invariant, it must be marked unsafe and pass the safety requirement to the caller. Fixes emilk#7743
45b88d6 to
8eb3b44
Compare
|
@emilk Actually there is a bit of a problem here. I think that if we really want to be 100% sound, then State::new should probably be unsafe as well, because again, the current function signature can't enforce that the safety requirements are actually upheld. |
The smithay-clipboard Clipboard::new method requires the display pointer to remain valid for the lifetime of the Clipboard. Since egui-winit's Clipboard::new cannot guarantee this invariant, it must be marked unsafe and pass the safety requirement to the caller.
Fixes #7743 (more details there)