Replace SendCell with fragile.
SendCell is depricated now and its advised to use the Fragile crate instead. https://github.com/sdroege/send-cell/issues/5
This commit is contained in:
@@ -19,10 +19,10 @@ log = "0.4.3"
|
||||
loggerv = "0.7.1"
|
||||
open = "1.2.1"
|
||||
rayon = "1.0.2"
|
||||
send-cell = "0.1.3"
|
||||
url = "1.7.1"
|
||||
failure = "0.1.1"
|
||||
failure_derive = "0.1.1"
|
||||
fragile = "0.2.1"
|
||||
regex = "1.0.2"
|
||||
reqwest = "0.8.6"
|
||||
serde_json = "1.0.24"
|
||||
|
||||
@@ -6,8 +6,8 @@ use gtk;
|
||||
use gtk::prelude::*;
|
||||
|
||||
use crossbeam_channel::{unbounded, Receiver, Sender};
|
||||
use fragile::Fragile;
|
||||
use podcasts_data::Show;
|
||||
use send_cell::SendCell;
|
||||
|
||||
use headerbar::Header;
|
||||
use prefs::Prefs;
|
||||
@@ -57,7 +57,7 @@ pub enum Action {
|
||||
RemoveShow(Arc<Show>),
|
||||
ErrorNotification(String),
|
||||
InitEpisode(i32),
|
||||
InitShowMenu(SendCell<ShowMenu>),
|
||||
InitShowMenu(Fragile<ShowMenu>),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -287,8 +287,8 @@ impl App {
|
||||
debug_assert!(res.is_ok());
|
||||
}
|
||||
Action::InitShowMenu(s) => {
|
||||
let menu = s.borrow();
|
||||
self.headerbar.set_secondary_menu(&menu.container);
|
||||
let menu = &s.get().container;
|
||||
self.headerbar.set_secondary_menu(menu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ extern crate pretty_assertions;
|
||||
|
||||
extern crate chrono;
|
||||
extern crate crossbeam_channel;
|
||||
extern crate fragile;
|
||||
extern crate html2text;
|
||||
extern crate humansize;
|
||||
extern crate loggerv;
|
||||
@@ -69,7 +70,6 @@ extern crate podcasts_downloader;
|
||||
extern crate rayon;
|
||||
extern crate regex;
|
||||
extern crate reqwest;
|
||||
extern crate send_cell;
|
||||
extern crate serde_json;
|
||||
extern crate url;
|
||||
|
||||
|
||||
@@ -10,10 +10,10 @@ use gtk::{IsA, Widget};
|
||||
use chrono::prelude::*;
|
||||
use crossbeam_channel::{unbounded, Sender};
|
||||
use failure::Error;
|
||||
use fragile::Fragile;
|
||||
use rayon;
|
||||
use regex::Regex;
|
||||
use reqwest;
|
||||
use send_cell::SendCell;
|
||||
use serde_json::Value;
|
||||
|
||||
// use podcasts_data::feed;
|
||||
@@ -213,7 +213,7 @@ where
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref CACHED_PIXBUFS: RwLock<HashMap<(i32, u32), Mutex<SendCell<Pixbuf>>>> =
|
||||
static ref CACHED_PIXBUFS: RwLock<HashMap<(i32, u32), Mutex<Fragile<Pixbuf>>>> =
|
||||
{ RwLock::new(HashMap::new()) };
|
||||
static ref COVER_DL_REGISTRY: RwLock<HashSet<i32>> = RwLock::new(HashSet::new());
|
||||
static ref THREADPOOL: rayon::ThreadPool = rayon::ThreadPoolBuilder::new().build().unwrap();
|
||||
@@ -248,12 +248,12 @@ pub fn set_image_from_path(image: >k::Image, show_id: i32, size: u32) -> Resul
|
||||
if let Some(guard) = hashmap.get(&(show_id, size)) {
|
||||
guard
|
||||
.lock()
|
||||
.map_err(|err| format_err!("SendCell Mutex: {}", err))
|
||||
.and_then(|sendcell| {
|
||||
sendcell
|
||||
.map_err(|err| format_err!("Fragile Mutex: {}", err))
|
||||
.and_then(|fragile| {
|
||||
fragile
|
||||
.try_get()
|
||||
.map(|px| image.set_from_pixbuf(px))
|
||||
.ok_or_else(|| format_err!("Pixbuf was accessed from a different thread"))
|
||||
.map_err(From::from)
|
||||
})?;
|
||||
|
||||
return Ok(());
|
||||
@@ -278,7 +278,7 @@ pub fn set_image_from_path(image: >k::Image, show_id: i32, size: u32) -> Resul
|
||||
if let Ok(path) = path {
|
||||
if let Ok(px) = Pixbuf::new_from_file_at_scale(&path, s, s, true) {
|
||||
if let Ok(mut hashmap) = CACHED_PIXBUFS.write() {
|
||||
hashmap.insert((show_id, size), Mutex::new(SendCell::new(px.clone())));
|
||||
hashmap.insert((show_id, size), Mutex::new(Fragile::new(px.clone())));
|
||||
image.set_from_pixbuf(&px);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ use gtk;
|
||||
use gtk::prelude::*;
|
||||
|
||||
use crossbeam_channel::Sender;
|
||||
use fragile::Fragile;
|
||||
use podcasts_data::dbqueries;
|
||||
use podcasts_data::EpisodeWidgetModel;
|
||||
use send_cell::SendCell;
|
||||
|
||||
use app::Action;
|
||||
use utils::{self, lazy_load_full};
|
||||
@@ -18,7 +18,7 @@ use std::rc::Rc;
|
||||
use std::sync::Mutex;
|
||||
|
||||
lazy_static! {
|
||||
pub static ref EPISODES_VIEW_VALIGNMENT: Mutex<Option<SendCell<gtk::Adjustment>>> =
|
||||
pub static ref EPISODES_VIEW_VALIGNMENT: Mutex<Option<Fragile<gtk::Adjustment>>> =
|
||||
Mutex::new(None);
|
||||
}
|
||||
|
||||
@@ -126,11 +126,15 @@ impl HomeView {
|
||||
.lock()
|
||||
.map_err(|err| format_err!("Failed to lock widget align mutex: {}", err))?;
|
||||
|
||||
if let Some(ref sendcell) = *guard {
|
||||
if let Some(ref fragile) = *guard {
|
||||
// Copy the vertical scrollbar adjustment from the old view into the new one.
|
||||
sendcell
|
||||
let res = fragile
|
||||
.try_get()
|
||||
.map(|x| utils::smooth_scroll_to(&self.scrolled_window, &x));
|
||||
.map(|x| utils::smooth_scroll_to(&self.scrolled_window, &x))
|
||||
.map_err(From::from);
|
||||
|
||||
debug_assert!(res.is_ok());
|
||||
return res;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -143,7 +147,7 @@ impl HomeView {
|
||||
.scrolled_window
|
||||
.get_vadjustment()
|
||||
.ok_or_else(|| format_err!("Could not get the adjustment"))?;
|
||||
*guard = Some(SendCell::new(adj));
|
||||
*guard = Some(Fragile::new(adj));
|
||||
info!("Saved episodes_view alignment.");
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ use glib::SignalHandlerId;
|
||||
use chrono::NaiveTime;
|
||||
use crossbeam_channel::Sender;
|
||||
use failure::Error;
|
||||
use send_cell::SendCell;
|
||||
use fragile::Fragile;
|
||||
|
||||
use podcasts_data::{dbqueries, USER_AGENT};
|
||||
use podcasts_data::{EpisodeWidgetModel, ShowCoverModel};
|
||||
@@ -300,25 +300,25 @@ impl PlayerWidget {
|
||||
}));
|
||||
|
||||
// The followign callbacks require `Send` but are handled by the gtk main loop
|
||||
let weak = SendCell::new(Rc::downgrade(s));
|
||||
let weak = Fragile::new(Rc::downgrade(s));
|
||||
|
||||
// Update the duration label and the slider
|
||||
s.player.connect_duration_changed(clone!(weak => move |_, clock| {
|
||||
weak.borrow()
|
||||
weak.get()
|
||||
.upgrade()
|
||||
.map(|p| p.timer.on_duration_changed(Duration(clock)));
|
||||
}));
|
||||
|
||||
// Update the position label and the slider
|
||||
s.player.connect_position_updated(clone!(weak => move |_, clock| {
|
||||
weak.borrow()
|
||||
weak.get()
|
||||
.upgrade()
|
||||
.map(|p| p.timer.on_position_updated(Position(clock)));
|
||||
}));
|
||||
|
||||
// Reset the slider to 0 and show a play button
|
||||
s.player.connect_end_of_stream(clone!(weak => move |_| {
|
||||
weak.borrow()
|
||||
weak.get()
|
||||
.upgrade()
|
||||
.map(|p| p.stop());
|
||||
}));
|
||||
|
||||
@@ -4,9 +4,9 @@ use gtk::prelude::*;
|
||||
|
||||
use crossbeam_channel::Sender;
|
||||
use failure::Error;
|
||||
use fragile::Fragile;
|
||||
use html2text;
|
||||
use rayon;
|
||||
use send_cell::SendCell;
|
||||
|
||||
use podcasts_data::dbqueries;
|
||||
use podcasts_data::Show;
|
||||
@@ -19,7 +19,7 @@ use std::rc::Rc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
lazy_static! {
|
||||
static ref SHOW_WIDGET_VALIGNMENT: Mutex<Option<(i32, SendCell<gtk::Adjustment>)>> =
|
||||
static ref SHOW_WIDGET_VALIGNMENT: Mutex<Option<(i32, Fragile<gtk::Adjustment>)>> =
|
||||
Mutex::new(None);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ impl ShowWidget {
|
||||
pdw.init(&pd);
|
||||
|
||||
let menu = ShowMenu::new(&pd, &pdw.episodes, &sender);
|
||||
sender.send(Action::InitShowMenu(SendCell::new(menu)));
|
||||
sender.send(Action::InitShowMenu(Fragile::new(menu)));
|
||||
|
||||
let pdw = Rc::new(pdw);
|
||||
let res = populate_listbox(&pdw, pd.clone(), sender);
|
||||
@@ -95,7 +95,7 @@ impl ShowWidget {
|
||||
.scrolled_window
|
||||
.get_vadjustment()
|
||||
.ok_or_else(|| format_err!("Could not get the adjustment"))?;
|
||||
*guard = Some((oldid, SendCell::new(adj)));
|
||||
*guard = Some((oldid, Fragile::new(adj)));
|
||||
debug!("Widget Alignment was saved with ID: {}.", oldid);
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ impl ShowWidget {
|
||||
.lock()
|
||||
.map_err(|err| format_err!("Failed to lock widget align mutex: {}", err))?;
|
||||
|
||||
if let Some((oldid, ref sendcell)) = *guard {
|
||||
if let Some((oldid, ref fragile)) = *guard {
|
||||
// Only copy the old scrollbar if both widget's represent the same podcast.
|
||||
debug!("PID: {}", pd.id());
|
||||
debug!("OLDID: {}", oldid);
|
||||
@@ -118,9 +118,13 @@ impl ShowWidget {
|
||||
};
|
||||
|
||||
// Copy the vertical scrollbar adjustment from the old view into the new one.
|
||||
sendcell
|
||||
let res = fragile
|
||||
.try_get()
|
||||
.map(|x| utils::smooth_scroll_to(&self.scrolled_window, &x));
|
||||
.map(|x| utils::smooth_scroll_to(&self.scrolled_window, &x))
|
||||
.map_err(From::from);
|
||||
|
||||
debug_assert!(res.is_ok());
|
||||
return res;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -3,7 +3,7 @@ use gtk::prelude::*;
|
||||
|
||||
use crossbeam_channel::Sender;
|
||||
use failure::Error;
|
||||
use send_cell::SendCell;
|
||||
use fragile::Fragile;
|
||||
|
||||
use podcasts_data::dbqueries;
|
||||
use podcasts_data::Show;
|
||||
@@ -17,7 +17,7 @@ use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
|
||||
lazy_static! {
|
||||
static ref SHOWS_VIEW_VALIGNMENT: Mutex<Option<SendCell<gtk::Adjustment>>> = Mutex::new(None);
|
||||
static ref SHOWS_VIEW_VALIGNMENT: Mutex<Option<Fragile<gtk::Adjustment>>> = Mutex::new(None);
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -65,11 +65,15 @@ impl ShowsView {
|
||||
.lock()
|
||||
.map_err(|err| format_err!("Failed to lock widget align mutex: {}", err))?;
|
||||
|
||||
if let Some(ref sendcell) = *guard {
|
||||
if let Some(ref fragile) = *guard {
|
||||
// Copy the vertical scrollbar adjustment from the old view into the new one.
|
||||
sendcell
|
||||
let res = fragile
|
||||
.try_get()
|
||||
.map(|x| utils::smooth_scroll_to(&self.scrolled_window, &x));
|
||||
.map(|x| utils::smooth_scroll_to(&self.scrolled_window, &x))
|
||||
.map_err(From::from);
|
||||
|
||||
debug_assert!(res.is_ok());
|
||||
return res;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -82,7 +86,7 @@ impl ShowsView {
|
||||
.scrolled_window
|
||||
.get_vadjustment()
|
||||
.ok_or_else(|| format_err!("Could not get the adjustment"))?;
|
||||
*guard = Some(SendCell::new(adj));
|
||||
*guard = Some(Fragile::new(adj));
|
||||
info!("Saved episodes_view alignment.");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user