diff --git a/collects/mred/private/wx/win32/utils.rkt b/collects/mred/private/wx/win32/utils.rkt index f9a288957a..b209ef095b 100644 --- a/collects/mred/private/wx/win32/utils.rkt +++ b/collects/mred/private/wx/win32/utils.rkt @@ -65,6 +65,12 @@ (define-kernel32 GetLastError (_wfun -> _DWORD)) (define (failed who) + ;; There's a race condition between this use of GetLastError() + ;; and other Racket threads that may have run since + ;; the call in this thread that we're reporting as failed. + ;; In the rare case that we lose a race, though, it just + ;; means a bad report for an error that shouldn't have happened + ;;; anyway. (error who "call failed (~s)" (GetLastError))) diff --git a/collects/mred/private/wx/win32/wndclass.rkt b/collects/mred/private/wx/win32/wndclass.rkt index 485b4a1f29..06f239bdb7 100644 --- a/collects/mred/private/wx/win32/wndclass.rkt +++ b/collects/mred/private/wx/win32/wndclass.rkt @@ -243,7 +243,7 @@ (cpointer-push-tag! p 'HBRUSH) p)) -(define-kernel32 GetModuleFileNameW (_wfun _pointer _pointer _DWORD -> _DWORD)) +(define-kernel32 GetModuleFileNameW (_wfun #:save-errno 'windows _pointer _pointer _DWORD -> _DWORD)) (define ERROR_INSUFFICIENT_BUFFER 122) (define-shell32 ExtractIconW (_wfun _HINSTANCE _string/utf-16 _UINT -> (r : _HICON) -> (or r (failed 'ExtractIconW)))) @@ -255,7 +255,7 @@ (let ([r (GetModuleFileNameW #f p size)]) (cond [(and (or (zero? r) (= r size)) - (= (GetLastError) ERROR_INSUFFICIENT_BUFFER)) + (= (saved-errno) ERROR_INSUFFICIENT_BUFFER)) (loop (* size 2))] [(zero? r) (failed 'GetModuleFileNameW)] [else (cast p _gcpointer _string/utf-16)]))))])