-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Describe the bug
Context::load_texture
acquires a read lock to the context's InputState
, which is unexpected. I discovered this by accidentally holding a handle from Context::input_mut
for longer than necessary, and calling load_texture
with it held. At time of writing, the lock is acquired here: https://github.com/emilk/egui/blob/master/crates/egui/src/context.rs#L755
To Reproduce
Steps to reproduce the behavior:
- Call
Context::input_mut
in your UI code to query user inputs. - Later (perhaps in response to user action consumed with
InputState::consume_key
), callContext::load_texture
, before theMappedRwLockWriteGuard
frominput_mut
is dropped.
I can write a minimal working example later if needed, but hopefully this is clear enough.
Expected behavior
Texture loading code would not interact with InputState
.
Screenshots
N/A
Desktop (please complete the following information):
This isn't OS specific.
Additional context
It seems strange that loading a texture would have anything to do with the user input, but this could reasonably be solved by documenting this behavior on Context::load_texture
. It's easy enough to work around (just drop the lock guard earlier), but it's tricky to realize what's happening without debugging egui code.