diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index aca9d2baa48..4cf69f69259 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -2018,7 +2018,10 @@ impl Context { pub fn try_load_bytes(&self, uri: &str) -> load::BytesLoadResult { crate::profile_function!(); - for loader in self.loaders().bytes.lock().iter() { + let loaders = self.loaders(); + let loaders = loaders.bytes.lock(); + + for loader in loaders.iter() { match loader.load(self, uri) { Err(load::LoadError::NotSupported) => continue, result => return result, @@ -2103,7 +2106,8 @@ impl Context { Err(load::LoadError::NotSupported) } - fn loaders(&self) -> Arc { + /// The loaders of bytes, images, and textures. + pub fn loaders(&self) -> Arc { crate::profile_function!(); self.read(|this| this.loaders.clone()) } diff --git a/crates/egui/src/load.rs b/crates/egui/src/load.rs index 8e77d15c897..9e0933b031d 100644 --- a/crates/egui/src/load.rs +++ b/crates/egui/src/load.rs @@ -75,7 +75,7 @@ pub enum LoadError { /// There are no image loaders installed. NoImageLoaders, - /// This loader does not support this protocol or image format. + /// This loader does not support this schema, protocol or image format. NotSupported, /// A custom error message (e.g. "File not found: foo.png"). @@ -487,7 +487,8 @@ type ImageLoaderImpl = Arc; type TextureLoaderImpl = Arc; #[derive(Clone)] -pub(crate) struct Loaders { +/// The loaders of bytes, images, and textures. +pub struct Loaders { pub include: Arc, pub bytes: Mutex>, pub image: Mutex>,