return impl->isFlipped(self, _cmd) ? YES:NO;
}
+typedef void (*wxOSX_DrawRectHandlerPtr)(NSView* self, SEL _cmd, NSRect rect);
+
void wxOSX_drawRect(NSView* self, SEL _cmd, NSRect rect)
{
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
if (impl == NULL)
return;
+#ifdef wxUSE_THREADS
+ // OS X starts a NSUIHeartBeatThread for animating the default button in a
+ // dialog. This causes a drawRect of the active dialog from outside the
+ // main UI thread. This causes an occasional crash since the wx drawing
+ // objects (like wxPen) are not thread safe.
+ //
+ // Notice that NSUIHeartBeatThread seems to be undocumented and doing
+ // [NSWindow setAllowsConcurrentViewDrawing:NO] does not affect it.
+ if ( !wxThread::IsMain() )
+ {
+ // just call the superclass handler, we don't need any custom wx drawing
+ // here and it seems to work fine:
+ wxOSX_DrawRectHandlerPtr
+ superimpl = (wxOSX_DrawRectHandlerPtr)
+ [[self superclass] instanceMethodForSelector:_cmd];
+ superimpl(self, _cmd, rect);
+ return;
+ }
+#endif // wxUSE_THREADS
+
return impl->drawRect(&rect, self, _cmd);
}
typedef BOOL (*wxOSX_PerformKeyEventHandlerPtr)(NSView* self, SEL _cmd, NSEvent *event);
typedef BOOL (*wxOSX_FocusHandlerPtr)(NSView* self, SEL _cmd);
typedef BOOL (*wxOSX_ResetCursorRectsHandlerPtr)(NSView* self, SEL _cmd);
-typedef void (*wxOSX_DrawRectHandlerPtr)(NSView* self, SEL _cmd, NSRect rect);
void wxWidgetCocoaImpl::mouseEvent(WX_NSEvent event, WXWidget slf, void *_cmd)
{
#if OSX_DEBUG_DRAWING
CGContextBeginPath( context );
CGContextMoveToPoint(context, 0, 0);
- NSRect bounds = [self bounds];
+ NSRect bounds = [slf bounds];
CGContextAddLineToPoint(context, 10, 0);
CGContextMoveToPoint(context, 0, 0);
CGContextAddLineToPoint(context, 0, 10);
wxInt32 wxWidgetCocoaImpl::GetMinimum() const
{
- if ( [m_osxView respondsToSelector:@selector(getMinValue:)] )
+ if ( [m_osxView respondsToSelector:@selector(minValue)] )
{
return (int)[m_osxView minValue];
}
wxInt32 wxWidgetCocoaImpl::GetMaximum() const
{
- if ( [m_osxView respondsToSelector:@selector(getMaxValue:)] )
+ if ( [m_osxView respondsToSelector:@selector(maxValue)] )
{
return (int)[m_osxView maxValue];
}