]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/utils.mm
Fix discrepancy between different ways of measuring text extents under Mac.
[wxWidgets.git] / src / osx / cocoa / utils.mm
index 194abcd750cd6dca6373ceaf514644622d98eb61..8d74b22883bea2e67eeb82301d8593aaa3fb5176 100644 (file)
@@ -52,9 +52,27 @@ void wxBell()
 
 void wxMacWakeUp()
 {
 
 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
 }
 
 #endif // wxUSE_BASE
@@ -148,9 +166,9 @@ void wxMacWakeUp()
 }
 @end
 
 }
 @end
 
-/* 
+/*
     allows ShowModal to work when using sheets.
     allows ShowModal to work when using sheets.
-    see include/wx/osx/cocoa/private.h for more info 
+    see include/wx/osx/cocoa/private.h for more info
 */
 @implementation ModalDialogDelegate
 - (id)init
 */
 @implementation ModalDialogDelegate
 - (id)init
@@ -161,7 +179,7 @@ void wxMacWakeUp()
     return self;
 }
 
     return self;
 }
 
-- (BOOL)finished 
+- (BOOL)finished
 {
     return sheetFinished;
 }
 {
     return sheetFinished;
 }
@@ -300,7 +318,7 @@ wxBitmap wxWindowDCImpl::DoGetAsBitmap(const wxRect *subrect) const
     // called from OnPaint, even with the window's paint dc as source (see wxHTMLWindow)
     NSBitmapImageRep *rep = [[[NSBitmapImageRep alloc] initWithFocusedViewRect: [view bounds]] retain];
     [view unlockFocus];
     // called from OnPaint, even with the window's paint dc as source (see wxHTMLWindow)
     NSBitmapImageRep *rep = [[[NSBitmapImageRep alloc] initWithFocusedViewRect: [view bounds]] retain];
     [view unlockFocus];
-    
+
     wxBitmap bitmap(width, height);
     if ( [rep respondsToSelector:@selector(CGImage)] )
     {
     wxBitmap bitmap(width, height);
     if ( [rep respondsToSelector:@selector(CGImage)] )
     {
@@ -323,4 +341,4 @@ wxBitmap wxWindowDCImpl::DoGetAsBitmap(const wxRect *subrect) const
 
 #endif // wxUSE_GUI
 
 
 #endif // wxUSE_GUI
 
-#endif // wxOSX_USE_COCOA
\ No newline at end of file
+#endif // wxOSX_USE_COCOA