From 421ce99a493fb6b40034cbe3fe1fa69f4c81b321 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 23 Apr 2013 11:10:52 -0600 Subject: [PATCH] ffi/unsafe/objc: remove `-A'/`+A', add `#:async-apply' Another run at the problem 57516164de was meant to solve. The new solution just gives up when a `drawRect:' method is called in the wrong thread, which might create refresh glitches but avoids a deadlock in the case that the Racket thread is blocked on the update happening in the foreign thread. original commit: ca0418d47d62426a4321ddfe7001466f7d87739e --- collects/mred/private/wx/cocoa/canvas.rkt | 12 ++++++++---- collects/mred/private/wx/cocoa/panel.rkt | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/collects/mred/private/wx/cocoa/canvas.rkt b/collects/mred/private/wx/cocoa/canvas.rkt index cbb99ea8..6613d6cb 100644 --- a/collects/mred/private/wx/cocoa/canvas.rkt +++ b/collects/mred/private/wx/cocoa/canvas.rkt @@ -65,7 +65,8 @@ (define-objc-mixin (RacketViewMixin Superclass) #:mixins (KeyMouseTextResponder CursorDisplayer FocusResponder) [wxb] - (-A _void (drawRect: [_NSRect r]) + (-a #:async-apply (box (void)) + _void (drawRect: [_NSRect r]) (when wxb (let ([wx (->wx wxb)]) (when wx @@ -98,7 +99,8 @@ (define-objc-class CornerlessFrameView NSView [] - (-A _void (drawRect: [_NSRect r]) + (-a #:async-apply (box (void)) + _void (drawRect: [_NSRect r]) (let ([ctx (tell NSGraphicsContext currentContext)]) (tellv ctx saveGraphicsState) (let ([cg (tell #:type _CGContextRef ctx graphicsPort)] @@ -129,7 +131,8 @@ [on?] (-a _void (setFocusState: [_BOOL is-on?]) (set! on? is-on?)) - (-A _void (drawRect: [_NSRect r]) + (-a #:async-apply (box (void)) + _void (drawRect: [_NSRect r]) (let ([f (tell #:type _NSRect self frame)]) (tellv bezel-cell drawWithFrame: #:type _NSRect (make-NSRect (make-NSPoint 2 2) @@ -154,7 +157,8 @@ #:mixins (FocusResponder KeyMouseTextResponder CursorDisplayer) #:protocols (NSComboBoxDelegate) [wxb] - (-A _void (drawRect: [_NSRect r]) + (-a #:async-apply (box (void)) + _void (drawRect: [_NSRect r]) (super-tell #:type _void drawRect: #:type _NSRect r) (let ([wx (->wx wxb)]) (when wx diff --git a/collects/mred/private/wx/cocoa/panel.rkt b/collects/mred/private/wx/cocoa/panel.rkt index 55962b19..00a91c12 100644 --- a/collects/mred/private/wx/cocoa/panel.rkt +++ b/collects/mred/private/wx/cocoa/panel.rkt @@ -22,7 +22,8 @@ (define-objc-class FrameView NSView [] - (-A _void (drawRect: [_NSRect r]) + (- #:async-apply (box (void)) + _void (drawRect: [_NSRect r]) (let ([ctx (tell NSGraphicsContext currentContext)]) (tellv ctx saveGraphicsState) (let ([cg (tell #:type _CGContextRef ctx graphicsPort)]