mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-23 10:26:34 +11:00
Merge pull request #733 from fkaa/cocoa-memleak
Fix memory leak while creating NSEvent and swapping buffers (Fixes #514)
This commit is contained in:
commit
a3543b700f
1 changed files with 13 additions and 1 deletions
|
@ -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() {
|
||||
|
@ -749,7 +757,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(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue