mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-25 06:41:31 +11:00
Fix memory leak while creating NSEvent and swapping buffers (Fixes #514)
This commit is contained in:
parent
2638db665a
commit
08c311839f
|
@ -224,12 +224,16 @@ impl<'a> Iterator for PollEventsIterator<'a> {
|
||||||
|
|
||||||
let event: Option<Event>;
|
let event: Option<Event>;
|
||||||
unsafe {
|
unsafe {
|
||||||
|
let pool = NSAutoreleasePool::new(nil);
|
||||||
|
|
||||||
let nsevent = NSApp().nextEventMatchingMask_untilDate_inMode_dequeue_(
|
let nsevent = NSApp().nextEventMatchingMask_untilDate_inMode_dequeue_(
|
||||||
NSAnyEventMask.bits() | NSEventMaskPressure.bits(),
|
NSAnyEventMask.bits() | NSEventMaskPressure.bits(),
|
||||||
NSDate::distantPast(nil),
|
NSDate::distantPast(nil),
|
||||||
NSDefaultRunLoopMode,
|
NSDefaultRunLoopMode,
|
||||||
YES);
|
YES);
|
||||||
event = NSEventToEvent(self.window, nsevent);
|
event = NSEventToEvent(self.window, nsevent);
|
||||||
|
|
||||||
|
let _: () = msg_send![pool, release];
|
||||||
}
|
}
|
||||||
event
|
event
|
||||||
}
|
}
|
||||||
|
@ -249,12 +253,16 @@ impl<'a> Iterator for WaitEventsIterator<'a> {
|
||||||
|
|
||||||
let event: Option<Event>;
|
let event: Option<Event>;
|
||||||
unsafe {
|
unsafe {
|
||||||
|
let pool = NSAutoreleasePool::new(nil);
|
||||||
|
|
||||||
let nsevent = NSApp().nextEventMatchingMask_untilDate_inMode_dequeue_(
|
let nsevent = NSApp().nextEventMatchingMask_untilDate_inMode_dequeue_(
|
||||||
NSAnyEventMask.bits() | NSEventMaskPressure.bits(),
|
NSAnyEventMask.bits() | NSEventMaskPressure.bits(),
|
||||||
NSDate::distantFuture(nil),
|
NSDate::distantFuture(nil),
|
||||||
NSDefaultRunLoopMode,
|
NSDefaultRunLoopMode,
|
||||||
YES);
|
YES);
|
||||||
event = NSEventToEvent(self.window, nsevent);
|
event = NSEventToEvent(self.window, nsevent);
|
||||||
|
|
||||||
|
let _: () = msg_send![pool, release];
|
||||||
}
|
}
|
||||||
|
|
||||||
if event.is_none() {
|
if event.is_none() {
|
||||||
|
@ -747,7 +755,11 @@ impl GlContext for Window {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue