From 710a3f25528675414a7dcf717372d449301278af Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Thu, 29 Mar 2018 15:19:13 +0300 Subject: [PATCH] Use SendCell::try_get instead of SendCell::into_inner --- hammond-gtk/src/utils.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hammond-gtk/src/utils.rs b/hammond-gtk/src/utils.rs index 76efbcd..391683d 100644 --- a/hammond-gtk/src/utils.rs +++ b/hammond-gtk/src/utils.rs @@ -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(()); } }