From 3c9565ad25d1bd86e307964811ceaef5de9c1324 Mon Sep 17 00:00:00 2001 From: Tomaka17 Date: Sun, 3 Aug 2014 17:27:48 +0200 Subject: Fix closed flag not being immediatly set on win32 --- src/win32/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/win32') diff --git a/src/win32/mod.rs b/src/win32/mod.rs index 891c783..dbcbd8a 100644 --- a/src/win32/mod.rs +++ b/src/win32/mod.rs @@ -133,6 +133,7 @@ impl Window { } } + // if one of the received events is `Closed`, setting `is_closed` to true if events.iter().find(|e| match e { &&::Closed => true, _ => false }).is_some() { use std::sync::atomics::Relaxed; self.is_closed.store(true, Relaxed); @@ -146,10 +147,21 @@ impl Window { pub fn wait_events(&self) -> Vec { match self.events_receiver.recv_opt() { Ok(ev) => { + // if the received event is `Closed`, setting `is_closed` to true + match ev { + ::Closed => { + use std::sync::atomics::Relaxed; + self.is_closed.store(true, Relaxed); + }, + _ => () + }; + + // looing for other possible events in the queue let mut result = self.poll_events(); result.insert(0, ev); result }, + Err(_) => { use std::sync::atomics::Relaxed; self.is_closed.store(true, Relaxed); -- cgit v1.2.3 From d574f6f1bbcdcc93649fe9daa18106a3cae61ef6 Mon Sep 17 00:00:00 2001 From: Tomaka17 Date: Sun, 3 Aug 2014 17:33:48 +0200 Subject: Fix GL context not being destroyed on win32 --- src/win32/mod.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/win32') diff --git a/src/win32/mod.rs b/src/win32/mod.rs index dbcbd8a..f29bf89 100644 --- a/src/win32/mod.rs +++ b/src/win32/mod.rs @@ -199,6 +199,9 @@ impl Window { #[unsafe_destructor] impl Drop for Window { fn drop(&mut self) { + use std::ptr; + unsafe { ffi::wglMakeCurrent(ptr::mut_null(), ptr::mut_null()); } + unsafe { ffi::wglDeleteContext(self.context); } unsafe { ffi::DestroyWindow(self.window); } } } -- cgit v1.2.3