From f7a567b84704359d539df00ad9ac6bb85cf4e2d7 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 3 Mar 2018 16:42:46 -0800 Subject: [PATCH] share a reference to the config --- src/font/mod.rs | 4 ++-- src/main.rs | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/font/mod.rs b/src/font/mod.rs index 039478ec7..f848063d0 100644 --- a/src/font/mod.rs +++ b/src/font/mod.rs @@ -31,14 +31,14 @@ type FontPtr = Rc>>; /// Matches and loads fonts for a given input style pub struct FontConfiguration { - config: Config, + config: Rc, fonts: RefCell>, system: FontSystemImpl, } impl FontConfiguration { /// Create a new empty configuration - pub fn new(config: Config) -> Self { + pub fn new(config: Rc) -> Self { Self { config, fonts: RefCell::new(HashMap::new()), diff --git a/src/main.rs b/src/main.rs index 35e794fd1..5c4cb696d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -373,7 +373,7 @@ impl GuiEventLoop { fn run_glium( master: pty::MasterPty, child: std::process::Child, - config: config::Config, + config: &Rc, fontconfig: FontConfiguration, terminal: term::Terminal, initial_pixel_width: u16, @@ -392,7 +392,8 @@ fn run_glium( fontconfig, config .colors - .map(|p| p.into()) + .as_ref() + .map(|p| p.clone().into()) .unwrap_or_else(term::color::ColorPalette::default), )?; @@ -421,13 +422,13 @@ fn run() -> Result<(), Error> { as if it were a login shell.", )) .get_matches(); - let config = config::Config::load()?; + let config = Rc::new(config::Config::load()?); println!("Using configuration: {:#?}", config); // First step is to figure out the font metrics so that we know how // big things are going to be. - let fontconfig = FontConfiguration::new(config.clone()); + let fontconfig = FontConfiguration::new(Rc::clone(&config)); let font = fontconfig.default_font()?; // we always load the cell_height for font 0, @@ -469,7 +470,7 @@ fn run() -> Result<(), Error> { run_glium( master, child, - config, + &config, fontconfig, terminal, initial_pixel_width,