cocoa: get file-dialog results atomically

Otherwise, the NSURL object that is returned from the dialog can
be relased before we get the result.
This commit is contained in:
Matthew Flatt 2015-01-23 15:37:37 -07:00
parent 027ce3bdc2
commit 99a04d5f52

View File

@ -103,11 +103,12 @@
(begin0
(if (zero? result)
#f
(if (memq 'multi style)
(let ([urls (tell ns URLs)])
(for/list ([i (in-range (tell #:type _NSUInteger urls count))])
(nsurl->string (tell urls objectAtIndex: #:type _NSUInteger i))))
(let ([url (tell ns URL)])
(nsurl->string url))))
(atomically
(if (memq 'multi style)
(let ([urls (tell ns URLs)])
(for/list ([i (in-range (tell #:type _NSUInteger urls count))])
(nsurl->string (tell urls objectAtIndex: #:type _NSUInteger i))))
(let ([url (tell ns URL)])
(nsurl->string url)))))
(release ns)))))