From 99a04d5f529c1580ab217a9144d217e30fbaddd7 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 23 Jan 2015 15:37:37 -0700 Subject: [PATCH] cocoa: get file-dialog results atomically Otherwise, the NSURL object that is returned from the dialog can be relased before we get the result. --- gui-lib/mred/private/wx/cocoa/filedialog.rkt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/gui-lib/mred/private/wx/cocoa/filedialog.rkt b/gui-lib/mred/private/wx/cocoa/filedialog.rkt index f907a537..8380ce30 100644 --- a/gui-lib/mred/private/wx/cocoa/filedialog.rkt +++ b/gui-lib/mred/private/wx/cocoa/filedialog.rkt @@ -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)))))