diff --git a/src/font/mod.rs b/src/font/mod.rs index 6d25b351a..5899aacf0 100644 --- a/src/font/mod.rs +++ b/src/font/mod.rs @@ -8,6 +8,7 @@ use self::hbwrap as harfbuzz; use std::cell::RefCell; use std::collections::HashMap; use std::rc::Rc; +use std::sync::Arc; pub mod system; pub use self::system::*; @@ -34,7 +35,7 @@ type FontPtr = Rc>>; /// Matches and loads fonts for a given input style pub struct FontConfiguration { - config: Rc, + config: Arc, fonts: RefCell>, system: Rc, metrics: RefCell>, @@ -120,7 +121,7 @@ impl std::str::FromStr for FontSystemSelection { impl FontConfiguration { /// Create a new empty configuration - pub fn new(config: Rc, system: FontSystemSelection) -> Self { + pub fn new(config: Arc, system: FontSystemSelection) -> Self { Self { config, fonts: RefCell::new(HashMap::new()), diff --git a/src/gliumwindows.rs b/src/gliumwindows.rs index e839e57eb..4efad080a 100644 --- a/src/gliumwindows.rs +++ b/src/gliumwindows.rs @@ -14,6 +14,7 @@ use glium; use glium::glutin::dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize}; use glium::glutin::{self, ElementState, MouseCursor}; use std::rc::Rc; +use std::sync::Arc; use term; use term::KeyCode; use term::KeyModifiers; @@ -28,7 +29,7 @@ struct Host { /// if is_some, holds position to be restored after exiting /// fullscreen mode. is_fullscreen: Option, - config: Rc, + config: Arc, fonts: Rc, } @@ -71,7 +72,7 @@ impl HostHelper for Host { pub struct GliumTerminalWindow { host: HostImpl, event_loop: Rc, - config: Rc, + config: Arc, fonts: Rc, renderer: Renderer, width: u16, @@ -92,7 +93,7 @@ impl TerminalWindow for GliumTerminalWindow { fn get_tabs_mut(&mut self) -> &mut Tabs { &mut self.tabs } - fn config(&self) -> &Rc { + fn config(&self) -> &Arc { &self.config } fn fonts(&self) -> &Rc { @@ -189,7 +190,7 @@ impl GliumTerminalWindow { pub fn new( event_loop: &Rc, fonts: &Rc, - config: &Rc, + config: &Arc, tab: &Rc, ) -> Result { let palette = config @@ -232,7 +233,7 @@ impl GliumTerminalWindow { display, window_position, is_fullscreen: None, - config: Rc::clone(config), + config: Arc::clone(config), fonts: Rc::clone(fonts), }); @@ -245,7 +246,7 @@ impl GliumTerminalWindow { Ok(GliumTerminalWindow { host, event_loop: Rc::clone(event_loop), - config: Rc::clone(config), + config: Arc::clone(config), fonts: Rc::clone(fonts), renderer, width, diff --git a/src/guicommon/window.rs b/src/guicommon/window.rs index f3d2a204b..7d89fa195 100644 --- a/src/guicommon/window.rs +++ b/src/guicommon/window.rs @@ -8,6 +8,7 @@ use crate::openpty; use failure::Error; use glium; use std::rc::Rc; +use std::sync::Arc; /// Reports the currently configured physical size of the display /// surface (physical pixels, not adjusted for dpi) and the current @@ -39,7 +40,7 @@ pub trait TerminalWindow { fn advise_renderer_of_resize(&mut self, width: u16, height: u16) -> Result<(), Error>; fn tab_was_created(&mut self, tab: &Rc) -> Result<(), Error>; fn deregister_tab(&mut self, tab_id: TabId) -> Result<(), Error>; - fn config(&self) -> &Rc; + fn config(&self) -> &Arc; fn fonts(&self) -> &Rc; fn get_dimensions(&self) -> Dimensions; fn resize_if_not_full_screen(&mut self, width: u16, height: u16) -> Result; diff --git a/src/guiloop/glutinloop.rs b/src/guiloop/glutinloop.rs index 0e0f5b483..782064e51 100644 --- a/src/guiloop/glutinloop.rs +++ b/src/guiloop/glutinloop.rs @@ -168,8 +168,8 @@ impl GuiSystem for GlutinGuiSystem { fn spawn_new_window( &self, - config: &Rc, - fontconfig: &Rc, + config: &Arc, + fontconfig: &Rc, tab: &Rc, ) -> Result<(), Error> { let window = GliumTerminalWindow::new(&self.event_loop, fontconfig, config, tab)?; @@ -228,7 +228,7 @@ impl GuiEventLoop { fn do_spawn_new_window( events: &Rc, - config: &Rc, + config: &Arc, fonts: &Rc, ) -> Result<(), Error> { let tab = spawn_tab(&config, None)?; @@ -241,11 +241,11 @@ impl GuiEventLoop { pub fn schedule_spawn_new_window( events: &Rc, - config: &Rc, + config: &Arc, fonts: &Rc, ) { let myself = Rc::clone(events); - let config = Rc::clone(config); + let config = Arc::clone(config); let fonts = Rc::clone(fonts); events.core.spawn(futures::future::poll_fn(move || { Self::do_spawn_new_window(&myself, &config, &fonts) diff --git a/src/guiloop/mod.rs b/src/guiloop/mod.rs index bb32e709d..9884e082d 100644 --- a/src/guiloop/mod.rs +++ b/src/guiloop/mod.rs @@ -90,7 +90,7 @@ pub trait GuiSystem { fn spawn_new_window( &self, - config: &Rc, + config: &Arc, fontconfig: &Rc, tab: &Rc, ) -> Result<(), Error>; diff --git a/src/guiloop/x11.rs b/src/guiloop/x11.rs index f88f3bb09..e27ce4599 100644 --- a/src/guiloop/x11.rs +++ b/src/guiloop/x11.rs @@ -102,7 +102,7 @@ impl super::GuiSystem for X11GuiSystem { } fn spawn_new_window( &self, - config: &Rc, + config: &Arc, fontconfig: &Rc, tab: &Rc, ) -> Result<(), Error> { @@ -231,7 +231,7 @@ impl GuiEventLoop { fn do_spawn_new_window( events: &Rc, - config: &Rc, + config: &Arc, fonts: &Rc, ) -> Result<(), Error> { let tab = spawn_tab(&config, None)?; @@ -244,11 +244,11 @@ impl GuiEventLoop { pub fn schedule_spawn_new_window( events: &Rc, - config: &Rc, + config: &Arc, fonts: &Rc, ) { let myself = Rc::clone(events); - let config = Rc::clone(config); + let config = Arc::clone(config); let fonts = Rc::clone(fonts); events.core.spawn(futures::future::poll_fn(move || { Self::do_spawn_new_window(&myself, &config, &fonts) diff --git a/src/main.rs b/src/main.rs index 2d35dcafc..89d899288 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,6 +14,7 @@ use structopt::StructOpt; mod xwindows; use std::rc::Rc; +use std::sync::Arc; mod config; mod futurecore; @@ -105,7 +106,7 @@ struct Opt { fn main() -> Result<(), Error> { let opts = Opt::from_args(); - let config = Rc::new(if opts.skip_config { + let config = Arc::new(if opts.skip_config { config::Config::default_config() } else { config::Config::load()? @@ -113,7 +114,7 @@ fn main() -> Result<(), Error> { println!("Using configuration: {:#?}\nopts: {:#?}", config, opts); let font_system = opts.font_system.unwrap_or(config.font_system); - let fontconfig = Rc::new(FontConfiguration::new(Rc::clone(&config), font_system)); + let fontconfig = Rc::new(FontConfiguration::new(Arc::clone(&config), font_system)); let cmd = if !opts.prog.is_empty() { Some(opts.prog.iter().map(|x| x.as_os_str()).collect()) @@ -131,7 +132,7 @@ fn main() -> Result<(), Error> { } fn spawn_tab( - config: &Rc, + config: &Arc, cmd: Option>, ) -> Result, Error> { let cmd = config.build_prog(cmd)?; @@ -165,7 +166,7 @@ fn spawn_window( mux: &Rc, gui: &GuiSystem, cmd: Option>, - config: &Rc, + config: &Arc, fontconfig: &Rc, ) -> Result<(), Error> { let tab = spawn_tab(config, cmd)?; diff --git a/src/xwindows/xwin.rs b/src/xwindows/xwin.rs index d790fef8a..c4607735b 100644 --- a/src/xwindows/xwin.rs +++ b/src/xwindows/xwin.rs @@ -20,7 +20,7 @@ struct Host { window: Window, event_loop: Rc, fonts: Rc, - config: Rc, + config: Arc, } impl HostHelper for Host { @@ -60,7 +60,7 @@ impl TerminalWindow for X11TerminalWindow { fn get_tabs_mut(&mut self) -> &mut Tabs { &mut self.tabs } - fn config(&self) -> &Rc { + fn config(&self) -> &Arc { &self.host.config } fn fonts(&self) -> &Rc { @@ -131,7 +131,7 @@ impl X11TerminalWindow { pub fn new( event_loop: &Rc, fonts: &Rc, - config: &Rc, + config: &Arc, tab: &Rc, ) -> Result { let palette = config @@ -159,7 +159,7 @@ impl X11TerminalWindow { let host = HostImpl::new(Host { window, event_loop: Rc::clone(event_loop), - config: Rc::clone(config), + config: Arc::clone(config), fonts: Rc::clone(fonts), });