Fix deadlock in the texture/image loaders (#3314)
This commit is contained in:
parent
ec671e754f
commit
2338a854f9
|
|
@ -1980,16 +1980,15 @@ impl Context {
|
||||||
/// [not_supported]: crate::load::LoadError::NotSupported
|
/// [not_supported]: crate::load::LoadError::NotSupported
|
||||||
/// [custom]: crate::load::LoadError::Custom
|
/// [custom]: crate::load::LoadError::Custom
|
||||||
pub fn try_load_bytes(&self, uri: &str) -> load::BytesLoadResult {
|
pub fn try_load_bytes(&self, uri: &str) -> load::BytesLoadResult {
|
||||||
self.read(|this| {
|
let loaders = self.loaders();
|
||||||
for loader in &this.loaders.bytes {
|
for loader in &loaders.bytes {
|
||||||
match loader.load(self, uri) {
|
match loader.load(self, uri) {
|
||||||
Err(load::LoadError::NotSupported) => continue,
|
Err(load::LoadError::NotSupported) => continue,
|
||||||
result => return result,
|
result => return result,
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Err(load::LoadError::NotSupported)
|
Err(load::LoadError::NotSupported)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Try loading the image from the given uri using any available image loaders.
|
/// Try loading the image from the given uri using any available image loaders.
|
||||||
|
|
@ -2009,16 +2008,15 @@ impl Context {
|
||||||
/// [not_supported]: crate::load::LoadError::NotSupported
|
/// [not_supported]: crate::load::LoadError::NotSupported
|
||||||
/// [custom]: crate::load::LoadError::Custom
|
/// [custom]: crate::load::LoadError::Custom
|
||||||
pub fn try_load_image(&self, uri: &str, size_hint: load::SizeHint) -> load::ImageLoadResult {
|
pub fn try_load_image(&self, uri: &str, size_hint: load::SizeHint) -> load::ImageLoadResult {
|
||||||
self.read(|this| {
|
let loaders = self.loaders();
|
||||||
for loader in &this.loaders.image {
|
for loader in &loaders.image {
|
||||||
match loader.load(self, uri, size_hint) {
|
match loader.load(self, uri, size_hint) {
|
||||||
Err(load::LoadError::NotSupported) => continue,
|
Err(load::LoadError::NotSupported) => continue,
|
||||||
result => return result,
|
result => return result,
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Err(load::LoadError::NotSupported)
|
Err(load::LoadError::NotSupported)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Try loading the texture from the given uri using any available texture loaders.
|
/// Try loading the texture from the given uri using any available texture loaders.
|
||||||
|
|
@ -2043,16 +2041,21 @@ impl Context {
|
||||||
texture_options: TextureOptions,
|
texture_options: TextureOptions,
|
||||||
size_hint: load::SizeHint,
|
size_hint: load::SizeHint,
|
||||||
) -> load::TextureLoadResult {
|
) -> load::TextureLoadResult {
|
||||||
self.read(|this| {
|
let loaders = self.loaders();
|
||||||
for loader in &this.loaders.texture {
|
|
||||||
match loader.load(self, uri, texture_options, size_hint) {
|
|
||||||
Err(load::LoadError::NotSupported) => continue,
|
|
||||||
result => return result,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Err(load::LoadError::NotSupported)
|
for loader in &loaders.texture {
|
||||||
})
|
match loader.load(self, uri, texture_options, size_hint) {
|
||||||
|
Err(load::LoadError::NotSupported) => continue,
|
||||||
|
result => return result,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Err(load::LoadError::NotSupported)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn loaders(&self) -> load::Loaders {
|
||||||
|
crate::profile_function!();
|
||||||
|
self.read(|this| this.loaders.clone()) // TODO(emilk): something less slow
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -396,6 +396,7 @@ impl TextureLoader for DefaultTextureLoader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
pub(crate) struct Loaders {
|
pub(crate) struct Loaders {
|
||||||
pub include: Arc<DefaultBytesLoader>,
|
pub include: Arc<DefaultBytesLoader>,
|
||||||
pub bytes: Vec<Arc<dyn BytesLoader + Send + Sync + 'static>>,
|
pub bytes: Vec<Arc<dyn BytesLoader + Send + Sync + 'static>>,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue