1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 11:32:48 -05:00

Ahem. Actually _checking_ that asynchronous askalg() worked would

have been helpful. Since async verify_ssh_host_key() worked, I
didn't think anything else could go wrong. How wrong I was.

[originally from svn r5331]
This commit is contained in:
Simon Tatham
2005-02-17 18:56:37 +00:00
parent 8574822b9b
commit fceaa2e4a7
3 changed files with 115 additions and 90 deletions

View File

@ -320,7 +320,7 @@ static void askalg_callback(void *ctx, int result)
{
struct algstate *state = (struct algstate *)ctx;
state->callback(state->ctx, result == 0);
state->callback(state->ctx, result == NSAlertFirstButtonReturn);
sfree(state);
}
@ -343,7 +343,7 @@ int askalg(void *frontend, const char *algtype, const char *algname,
state->callback = callback;
state->ctx = ctx;
alert = [NSAlert alloc];
alert = [[NSAlert alloc] init];
[alert setInformativeText:[NSString stringWithCString:text]];
[alert addButtonWithTitle:@"Yes"];
[alert addButtonWithTitle:@"No"];

View File

@ -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