From: Vadim Zeitlin Date: Tue, 6 Oct 2009 00:08:15 +0000 (+0000) Subject: Create an NSAutoreleasePool in wxMacWakeUp(). X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/3c7eea25638c6535d11e248ef8c4621f6ccd791b Create an NSAutoreleasePool in wxMacWakeUp(). An auto-release pool is needed in this function because it can be called from another thread which has no reason to have a pre-existing pool, but it does allocate NSEvent object which is auto-released, resulting in warnings if no pool available. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62310 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/osx/cocoa/utils.mm b/src/osx/cocoa/utils.mm index 4b22268b3f..8d74b22883 100644 --- a/src/osx/cocoa/utils.mm +++ b/src/osx/cocoa/utils.mm @@ -52,9 +52,27 @@ void wxBell() void wxMacWakeUp() { - NSEvent* wakeupEvent = [NSEvent otherEventWithType:NSApplicationDefined location:NSZeroPoint - modifierFlags:NSAnyEventMask timestamp:0 windowNumber:0 context:nil subtype:0 data1:0 data2:0]; - [NSApp postEvent:wakeupEvent atStart:NO]; + // ensure that we have an auto release pool in place because the event will + // be autoreleased from NSEvent:otherEventWithType and we might not have a + // global pool during startup or shutdown and we actually never have it if + // we're called from another thread + // + // FIXME: we can't use wxMacAutoreleasePool here because it's in core and + // we're in base + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + NSEvent* wakeupEvent = [NSEvent otherEventWithType:NSApplicationDefined + location:NSZeroPoint + modifierFlags:NSAnyEventMask + timestamp:0 + windowNumber:0 + context:nil + subtype:0 + data1:0 + data2:0]; + [NSApp postEvent:wakeupEvent atStart:NO]; + + [pool release]; } #endif // wxUSE_BASE @@ -323,4 +341,4 @@ wxBitmap wxWindowDCImpl::DoGetAsBitmap(const wxRect *subrect) const #endif // wxUSE_GUI -#endif // wxOSX_USE_COCOA \ No newline at end of file +#endif // wxOSX_USE_COCOA