From cbf927acabc00962f29f7ef578bcc97edc8b72bb Mon Sep 17 00:00:00 2001 From: daa84 Date: Fri, 2 Feb 2018 12:17:19 +0300 Subject: [PATCH] Fix #54 panic --- src/ui.rs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/ui.rs b/src/ui.rs index 65bcd2b..bd389f8 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -129,7 +129,7 @@ impl Ui { .unwrap_or(true); if app.prefers_app_menu() || use_header_bar { - self.create_main_menu(app); + self.create_main_menu(app, &window); } if use_header_bar { @@ -220,8 +220,7 @@ impl Ui { })); } - fn create_main_menu(&self, app: >k::Application) { - let comps = self.comps.clone(); + fn create_main_menu(&self, app: >k::Application, window: >k::ApplicationWindow) { let plug_manager = self.plug_manager.clone(); let menu = Menu::new(); @@ -240,17 +239,11 @@ impl Ui { let plugs_action = SimpleAction::new("Plugins", None); plugs_action.connect_activate( - clone!(comps => move |_, _| plug_manager::Ui::new(&plug_manager).show( - comps - .borrow() - .window - .as_ref() - .unwrap(), - )), + clone!(window => move |_, _| plug_manager::Ui::new(&plug_manager).show(&window)), ); let about_action = SimpleAction::new("HelpAbout", None); - about_action.connect_activate(move |_, _| on_help_about(&*comps.borrow())); + about_action.connect_activate(clone!(window => move |_, _| on_help_about(&window))); about_action.set_enabled(true); app.add_action(&about_action); @@ -258,9 +251,9 @@ impl Ui { } } -fn on_help_about(comps: &Components) { +fn on_help_about(window: >k::ApplicationWindow) { let about = AboutDialog::new(); - about.set_transient_for(comps.window.as_ref()); + about.set_transient_for(window); about.set_program_name("NeovimGtk"); about.set_version(env!("CARGO_PKG_VERSION")); about.set_logo_icon_name("org.daa.NeovimGtk");