Use SendCell::try_get instead of SendCell::into_inner

This commit is contained in:
Jordan Petridis 2018-03-29 15:19:13 +03:00
parent 6071c664e7
commit 710a3f2552
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6

View File

@ -179,8 +179,10 @@ pub fn set_image_from_path(
if let Some(px) = hashmap.get(&(pd.id(), size)) {
let m = px.lock()
.map_err(|_| format_err!("Failed to lock pixbuf mutex."))?;
let px = m.clone().into_inner();
image.set_from_pixbuf(&px);
let px = m.try_get().ok_or_else(|| {
format_err!("Pixbuf was accessed from a different thread than created")
})?;
image.set_from_pixbuf(px);
return Ok(());
}
}