...
 
Commits (1)
...@@ -201,19 +201,21 @@ pub fn set_image_from_path( ...@@ -201,19 +201,21 @@ pub fn set_image_from_path(
let image = image.clone(); let image = image.clone();
let s = size as i32; let s = size as i32;
gtk::timeout_add(25, move || { gtk::timeout_add(25, move || {
if let Ok(path) = receiver.try_recv() { receiver
if let Ok(path) = path { .try_recv()
if let Ok(px) = Pixbuf::new_from_file_at_scale(&path, s, s, true) { .map(|res| {
if let Ok(mut hashmap) = CACHED_PIXBUFS.write() { res.ok()
hashmap.insert((pd.id(), size), Mutex::new(SendCell::new(px.clone()))); .and_then(|path| Pixbuf::new_from_file_at_scale(&path, s, s, true).ok())
image.set_from_pixbuf(&px); .map(|px| {
} if let Ok(mut hashmap) = CACHED_PIXBUFS.write() {
} hashmap.insert((pd.id(), size), Mutex::new(SendCell::new(px.clone())));
} image.set_from_pixbuf(&px);
glib::Continue(false) }
} else { })
glib::Continue(true) .map(|_| glib::Continue(false))
} .unwrap_or(glib::Continue(false))
})
.unwrap_or(glib::Continue(true))
}); });
Ok(()) Ok(())
} }
......