]> git.saurik.com Git - wxWidgets.git/commitdiff
Create an NSAutoreleasePool in wxMacWakeUp().
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 6 Oct 2009 00:08:15 +0000 (00:08 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 6 Oct 2009 00:08:15 +0000 (00:08 +0000)
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

src/osx/cocoa/utils.mm

index 4b22268b3ff215ba75faa8d8548b48e7d0e6a0cf..8d74b22883bea2e67eeb82301d8593aaa3fb5176 100644 (file)
@@ -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