ShowMenu: Fix a reference cycle

This commit is contained in:
Jordan Petridis 2018-08-13 06:48:39 +03:00
parent cc4b3cce55
commit b8bb5e6d82
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6

View File

@ -68,8 +68,13 @@ impl ShowMenu {
} }
fn connect_played(&self, pd: &Arc<Show>, episodes: &gtk::ListBox, sender: &Sender<Action>) { fn connect_played(&self, pd: &Arc<Show>, episodes: &gtk::ListBox, sender: &Sender<Action>) {
self.played let episodes_weak = episodes.downgrade();
.connect_clicked(clone!(pd, episodes, sender => move |_| { self.played.connect_clicked(clone!(pd, sender => move |_| {
let episodes = match episodes_weak.upgrade() {
Some(e) => e,
None => return,
};
let res = dim_titles(&episodes); let res = dim_titles(&episodes);
debug_assert!(res.is_some()); debug_assert!(res.is_some());
@ -121,6 +126,7 @@ fn dim_titles(episodes: &gtk::ListBox) -> Option<()> {
} }
fn mark_all_watched(pd: &Show, sender: &Sender<Action>) -> Result<(), Error> { fn mark_all_watched(pd: &Show, sender: &Sender<Action>) -> Result<(), Error> {
// TODO: If this fails for whatever reason, it should be impossible, show an error
dbqueries::update_none_to_played_now(pd)?; dbqueries::update_none_to_played_now(pd)?;
// Not all widgets might have been loaded when the mark_all is hit // Not all widgets might have been loaded when the mark_all is hit
// So we will need to refresh again after it's done. // So we will need to refresh again after it's done.