diff --git a/fractal-gtk/src/actions/global.rs b/fractal-gtk/src/actions/global.rs index 06187cfc..afec9d03 100644 --- a/fractal-gtk/src/actions/global.rs +++ b/fractal-gtk/src/actions/global.rs @@ -255,10 +255,16 @@ pub fn new(app: >k::Application, op: &Arc>) { back.borrow_mut().push(AppState::MediaViewer); }); + let mv_weak = Rc::downgrade(&op.lock().unwrap().media_viewer); let back_weak = Rc::downgrade(&back_history); back.connect_activate(move |_, _| { + let mv = upgrade_weak!(mv_weak); + if let Some(mut mv) = mv.borrow_mut().take() { + mv.disconnect_signal_id(); + } + + // Remove the current state from the store back_weak.upgrade().map(|back| { - // Remove the current state form the store back.borrow_mut().pop(); if let Some(state) = back.borrow().last() { debug!("Go back to state {:?}", state); @@ -267,7 +273,7 @@ pub fn new(app: >k::Application, op: &Arc>) { op.set_state(state.clone()); } } else { - // Falback when there is no back history + // Fallback when there is no back history debug!("There is no state to go back to. Go back to state NoRoom"); if let Some(op) = App::get_op() { let mut op = op.lock().unwrap(); diff --git a/fractal-gtk/src/appop/media_viewer.rs b/fractal-gtk/src/appop/media_viewer.rs index 2db26d5a..8e2ed0e0 100644 --- a/fractal-gtk/src/appop/media_viewer.rs +++ b/fractal-gtk/src/appop/media_viewer.rs @@ -2,8 +2,6 @@ use gtk; use gtk::prelude::*; use log::error; -use std::cell::RefCell; -use std::rc::Rc; use crate::actions; @@ -75,18 +73,6 @@ impl AppOp { stack.add_named(&body, "media-viewer"); stack_header.add_named(&header, "media-viewer"); - - let media_viewer_back_button = panel - .builder - .get_object::("media_viewer_back_button") - .expect("Can't find media_viewer_back_button in ui file."); - self.media_viewer = Rc::new(RefCell::new(Some(panel))); - let mv = self.media_viewer.clone(); - media_viewer_back_button.connect_clicked(move |_| { - if let Some(mut mv) = mv.borrow_mut().take() { - mv.disconnect_signal_id(); - } - }); } self.set_state(AppState::MediaViewer);