racket/gui cocoa: fix for Mac OS X before 10.7

I forgot to guard a NSScreen method called for Retina support
with a version check.
This commit is contained in:
Matthew Flatt 2013-11-19 07:16:04 -07:00
parent 8323e679eb
commit b64f74bbed

View File

@ -110,20 +110,22 @@
(tellv ctx restoreGraphicsState))) (tellv ctx restoreGraphicsState)))
(define (display-bitmap-resolution num fail) (define (display-bitmap-resolution num fail)
(let ([r (atomically (if (version-10.7-or-later?)
(with-autorelease (let ([r (atomically
(let ([s (if (zero? num) (with-autorelease
(tell NSScreen mainScreen) (let ([s (if (zero? num)
(let ([screens (tell NSScreen screens)]) (tell NSScreen mainScreen)
(if (num . < . (tell #:type _NSUInteger screens count)) (let ([screens (tell NSScreen screens)])
(tell screens objectAtIndex: #:type _NSUInteger num) (if (num . < . (tell #:type _NSUInteger screens count))
#f)))]) (tell screens objectAtIndex: #:type _NSUInteger num)
(and s #f)))])
(tell #:type _CGFloat s backingScaleFactor)))))]) (and s
(cond (tell #:type _CGFloat s backingScaleFactor)))))])
[(not r) (fail)] (cond
[(zero? r) 1.0] [(not r) (fail)]
[else r]))) [(zero? r) 1.0]
[else r]))
1.0))
(define/top (make-screen-bitmap [exact-positive-integer? w] (define/top (make-screen-bitmap [exact-positive-integer? w]
[exact-positive-integer? h]) [exact-positive-integer? h])