X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/3d9449a111194530856126f3dc89543d83fa0440..4763c1c2d66bb323b2b94a342cc39abbf1b0b1cb:/macosx/osxwin.m diff --git a/macosx/osxwin.m b/macosx/osxwin.m index 8166f913..0424b0b6 100644 --- a/macosx/osxwin.m +++ b/macosx/osxwin.m @@ -794,8 +794,28 @@ printf("n=%d c=U+%04x cm=U+%04x m=%08x\n", n, c, cm, m); - (void)alertSheetDidEnd:(NSAlert *)alert returnCode:(int)returnCode contextInfo:(void *)contextInfo { - alert_callback(alert_ctx, returnCode); /* transfers ownership of ctx */ + [self performSelectorOnMainThread: + @selector(alertSheetDidFinishEnding:) + withObject:[NSNumber numberWithInt:returnCode] + waitUntilDone:NO]; +} + +- (void)alertSheetDidFinishEnding:(id)object +{ + int returnCode = [object intValue]; + void (*this_callback)(void *, int); + void *this_ctx; + + /* + * We must save the values of our alert_callback and alert_ctx + * fields, in case they are set up again by the callback + * function! + */ + this_callback = alert_callback; + this_ctx = alert_ctx; alert_ctx = NULL; + + this_callback(this_ctx, returnCode); /* transfers ownership of ctx */ } @end