From f2444f151cd04dee9ec8f2b169bac4fa62c36d6f Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Thu, 29 Mar 2018 15:26:44 +0300 Subject: [PATCH] h-gtk/utils: Re-work format_err! calls and improve formatting --- hammond-data/src/models/new_podcast.rs | 6 +++--- hammond-gtk/src/utils.rs | 16 +++++++--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/hammond-data/src/models/new_podcast.rs b/hammond-data/src/models/new_podcast.rs index 4eb3ac6..97aaaa0 100644 --- a/hammond-data/src/models/new_podcast.rs +++ b/hammond-data/src/models/new_podcast.rs @@ -231,9 +231,9 @@ mod tests { love, a crashed UFO, an alien body, and an impossible heist unlike any \ ever attempted - scripted by Mac Rogers, the award-winning playwright \ and writer of the multi-million download The Message and LifeAfter.

"; - let img = "https://dfkfj8j276wwv.cloudfront.net/images/2c/5f/a0/1a/2c5fa01a-ae78-4a8c-\ - b183-7311d2e436c3/b3a4aa57a576bb662191f2a6bc2a436c8c4ae256ecffaff5c4c54fd42e\ - 923914941c264d01efb1833234b52c9530e67d28a8cebbe3d11a4bc0fbbdf13ecdf1c3.jpeg"; + let img = "https://dfkfj8j276wwv.cloudfront.net/images/2c/5f/a0/1a/2c5fa01a-ae78-4a8c-\ + b183-7311d2e436c3/b3a4aa57a576bb662191f2a6bc2a436c8c4ae256ecffaff5c4c54fd42e\ + 923914941c264d01efb1833234b52c9530e67d28a8cebbe3d11a4bc0fbbdf13ecdf1c3.jpeg"; NewPodcastBuilder::default() .title("Steal the Stars") diff --git a/hammond-gtk/src/utils.rs b/hammond-gtk/src/utils.rs index 391683d..247dd26 100644 --- a/hammond-gtk/src/utils.rs +++ b/hammond-gtk/src/utils.rs @@ -161,13 +161,11 @@ pub fn set_image_from_path( .read() .map_err(|err| format_err!("Cover Registry: {}.", err))?; if reg_guard.contains(&pd.id()) { - gtk::timeout_add( - 250, - clone!(image, pd => move || { - let _ = set_image_from_path(&image, pd.clone(), size); - glib::Continue(false) - }), - ); + let callback = clone!(image, pd => move || { + let _ = set_image_from_path(&image, pd.clone(), size); + glib::Continue(false) + }); + gtk::timeout_add(250, callback); return Ok(()); } } @@ -175,10 +173,10 @@ pub fn set_image_from_path( { let hashmap = CACHED_PIXBUFS .read() - .map_err(|_| format_err!("Failed to get a lock on the pixbuf cache mutex."))?; + .map_err(|err| format_err!("Pixbuf HashMap: {}", err))?; if let Some(px) = hashmap.get(&(pd.id(), size)) { let m = px.lock() - .map_err(|_| format_err!("Failed to lock pixbuf mutex."))?; + .map_err(|err| format_err!("SendCell Mutex: {}", err))?; let px = m.try_get().ok_or_else(|| { format_err!("Pixbuf was accessed from a different thread than created") })?;