fix(tiny-skia): avoid panic if image is not allocated
This commit is contained in:
parent
ac24bbe80d
commit
5f97135c3d
1 changed files with 11 additions and 14 deletions
|
|
@ -152,21 +152,18 @@ impl Cache {
|
|||
}
|
||||
|
||||
let _ = self.hits.insert(id);
|
||||
let Some(ret) = self.entries.get(&id).unwrap().as_ref().map(|entry| {
|
||||
tiny_skia::PixmapRef::from_bytes(
|
||||
bytemuck::cast_slice(&entry.pixels),
|
||||
entry.width,
|
||||
entry.height,
|
||||
)
|
||||
.expect("Build pixmap from image bytes")
|
||||
}) else {
|
||||
return Err(raster::Error::Empty);
|
||||
};
|
||||
|
||||
Ok(self
|
||||
.entries
|
||||
.get(&id)
|
||||
.unwrap()
|
||||
.as_ref()
|
||||
.map(|entry| {
|
||||
tiny_skia::PixmapRef::from_bytes(
|
||||
bytemuck::cast_slice(&entry.pixels),
|
||||
entry.width,
|
||||
entry.height,
|
||||
)
|
||||
.expect("Build pixmap from image bytes")
|
||||
})
|
||||
.expect("Image should be allocated"))
|
||||
Ok(ret)
|
||||
}
|
||||
|
||||
fn trim(&mut self) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue