Fix texture_as_hal internal unwrap may cause panic (#3131)

This commit is contained in:
Jinlei Li 2022-10-27 05:13:43 +08:00 committed by GitHub
parent d81cb46be0
commit dcc0baa1ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -385,7 +385,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let mut token = Token::root();
let (guard, _) = hub.textures.read(&mut token);
let texture = guard.try_get(id).ok().flatten();
let hal_texture = texture.map(|tex| tex.inner.as_raw().unwrap());
let hal_texture = texture.and_then(|tex| tex.inner.as_raw());
hal_texture_callback(hal_texture);
}