mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 23:08:05 +08:00
Fix corrupted font resource loading in older documents
This commit is contained in:
committed by
Dennis Kobert
parent
8d2645e20c
commit
71fdf3746a
@@ -258,12 +258,18 @@ pub fn editor_api(_: impl Ctx, #[scope("editor-api")] editor_api: Arc<PlatformEd
|
||||
pub fn resource(_: impl Ctx, hash: ResourceHash, #[scope(editor_api::IDENTIFIER)] editor_api: Arc<PlatformEditorApi>) -> SourceFuture<GPoll<Resource>> {
|
||||
let application_io = editor_api.application_io.clone();
|
||||
Box::pin(async move {
|
||||
// A missing resource degrades to an empty placeholder rather than failing the graph, so a document
|
||||
// whose stored bytes went missing (evicted browser storage, or an interrupted write) still opens
|
||||
let Some(application_io) = application_io else {
|
||||
return GPoll::error("ApplicationIo not available");
|
||||
log::error!("Resource {hash} is unavailable because the platform's application IO is missing");
|
||||
return GPoll::Final(Resource::empty());
|
||||
};
|
||||
match application_io.load_resource(hash).await {
|
||||
Some(resource) => GPoll::Final(resource),
|
||||
None => GPoll::error("resource not found"),
|
||||
None => {
|
||||
log::error!("Resource {hash} was not found in storage");
|
||||
GPoll::Final(Resource::empty())
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user