Borrow glutin::Window instead of using Arc

glutin::Window is not threadsafe; putting it into an Arc is
misleading (although the glutin::Window type claims to be Send + Sync).
The reference was just needed on the main thread anyway, so it's better
to just pass a ref around directly.
This commit is contained in:
Joe Wilm 2016-12-04 13:29:08 -08:00
parent ce32eee099
commit 43397cefec
1 changed files with 12 additions and 13 deletions

View File

@ -183,7 +183,6 @@ fn main() {
let signal_flag = Flag::new(false); let signal_flag = Flag::new(false);
let terminal = Arc::new(FairMutex::new(terminal)); let terminal = Arc::new(FairMutex::new(terminal));
let window = Arc::new(window);
// Setup the rsize callback for osx // Setup the rsize callback for osx
let terminal_ref = terminal.clone(); let terminal_ref = terminal.clone();
@ -215,7 +214,7 @@ fn main() {
// Wraps a renderer and gives simple draw() api. // Wraps a renderer and gives simple draw() api.
let mut display = Display::new( let mut display = Display::new(
window.clone(), &window,
renderer, renderer,
glyph_cache, glyph_cache,
render_timer, render_timer,
@ -290,8 +289,8 @@ impl config::OnConfigReload for ConfigHandler {
} }
} }
struct Display { struct Display<'a> {
window: Arc<glutin::Window>, window: &'a glutin::Window,
renderer: QuadRenderer, renderer: QuadRenderer,
glyph_cache: GlyphCache, glyph_cache: GlyphCache,
render_timer: bool, render_timer: bool,
@ -300,20 +299,20 @@ struct Display {
pty: Pty, pty: Pty,
} }
impl Display { impl<'a> Display<'a> {
pub fn update_config(&mut self, config: &Config) { pub fn update_config(&mut self, config: &Config) {
self.renderer.update_config(config); self.renderer.update_config(config);
self.render_timer = config.render_timer(); self.render_timer = config.render_timer();
} }
pub fn new(window: Arc<glutin::Window>, pub fn new(
renderer: QuadRenderer, window: &glutin::Window,
glyph_cache: GlyphCache, renderer: QuadRenderer,
render_timer: bool, glyph_cache: GlyphCache,
rx: mpsc::Receiver<(u32, u32)>, render_timer: bool,
pty: Pty) rx: mpsc::Receiver<(u32, u32)>,
-> Display pty: Pty
{ ) -> Display {
Display { Display {
window: window, window: window,
renderer: renderer, renderer: renderer,