aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFelix Kaaman <trundmatu@gmail.com>2016-03-02 16:40:19 +0100
committerFelix Kaaman <trundmatu@gmail.com>2016-03-02 16:44:08 +0100
commit08c311839f9c65faa358b0540a3ff6b2eb19ff14 (patch)
tree96fec56da15a86d3c01f14c8fe583d8062041b1d /src
parent2638db665afc175cf128c3e25bc883f4c114bb5a (diff)
downloadglutin-08c311839f9c65faa358b0540a3ff6b2eb19ff14.tar.gz
glutin-08c311839f9c65faa358b0540a3ff6b2eb19ff14.zip
Fix memory leak while creating NSEvent and swapping buffers (Fixes #514)
Diffstat (limited to 'src')
-rw-r--r--src/api/cocoa/mod.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/api/cocoa/mod.rs b/src/api/cocoa/mod.rs
index abcd735..ca77ce9 100644
--- a/src/api/cocoa/mod.rs
+++ b/src/api/cocoa/mod.rs
@@ -224,12 +224,16 @@ impl<'a> Iterator for PollEventsIterator<'a> {
let event: Option<Event>;
unsafe {
+ let pool = NSAutoreleasePool::new(nil);
+
let nsevent = NSApp().nextEventMatchingMask_untilDate_inMode_dequeue_(
NSAnyEventMask.bits() | NSEventMaskPressure.bits(),
NSDate::distantPast(nil),
NSDefaultRunLoopMode,
YES);
event = NSEventToEvent(self.window, nsevent);
+
+ let _: () = msg_send![pool, release];
}
event
}
@@ -249,12 +253,16 @@ impl<'a> Iterator for WaitEventsIterator<'a> {
let event: Option<Event>;
unsafe {
+ let pool = NSAutoreleasePool::new(nil);
+
let nsevent = NSApp().nextEventMatchingMask_untilDate_inMode_dequeue_(
NSAnyEventMask.bits() | NSEventMaskPressure.bits(),
NSDate::distantFuture(nil),
NSDefaultRunLoopMode,
YES);
event = NSEventToEvent(self.window, nsevent);
+
+ let _: () = msg_send![pool, release];
}
if event.is_none() {
@@ -747,7 +755,11 @@ impl GlContext for Window {
#[inline]
fn swap_buffers(&self) -> Result<(), ContextError> {
- unsafe { self.context.flushBuffer(); }
+ unsafe {
+ let pool = NSAutoreleasePool::new(nil);
+ self.context.flushBuffer();
+ let _: () = msg_send![pool, release];
+ }
Ok(())
}