-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Program crashes when setting ctx.set_pixels_per_point #4187
Comments
I think you just have a deadlock. As noted in input's documentation, you can't use the context inside the closure. Just move the egui/crates/egui/src/gui_zoom.rs Lines 6 to 46 in 820fa3c
(I don't know why the same doesn't happen with Ctrl- though) Edit: oh wait, you were probably testing by pressing |
As @YgorSouza pointed out, a ctx cannot be modified from within the closure, something I must have missed. This is very unsafe, is there a way we could restrict the use of input so these sort of accidents' don't happen in the future? |
Unfortunately, Rust does not consider deadlocks unsafe (nor does any language I think), and it's basically impossible to prevent them at compile time. The best we can do is avoid locks (and interior mutability in general) as much as possible, and document places where it can cause problems. There have been issues like this inside egui itself as well (like #2753). Maybe there is a better pattern that egui could have used, but no one has figured it out yet. |
Verify that issue has not been patched
The Bug
ctx.set_pixels_per_point(p)
Desktop Information
Related Code
This code runs at the end of every update. The issue persists when running at the beginning of every update.
The text was updated successfully, but these errors were encountered: