mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 09:12:24 +00:00
Sort out close-on-exit, connection_fatal(), fatalbox(), and
[SessionWindow dealloc] (which was required in order to avoid segfaulting when a redraw timer fired for a closed session window!). [originally from svn r5400]
This commit is contained in:
parent
f9363925c6
commit
fe8114d90b
@ -18,10 +18,10 @@ say you weren't warned!
|
||||
|
||||
Other ways in which the port is currently unfinished include:
|
||||
|
||||
- terminal display is horribly slow
|
||||
Missing terminal window features
|
||||
--------------------------------
|
||||
|
||||
- fatal errors are currently output via printf, which is obviously
|
||||
wrong for a GUI application
|
||||
- terminal display is horribly slow
|
||||
|
||||
- fonts aren't configurable
|
||||
|
||||
@ -38,32 +38,45 @@ Other ways in which the port is currently unfinished include:
|
||||
starting position, plus remembering previous window positions per
|
||||
the Apple HIG) is not implemented
|
||||
|
||||
- close-on-exit isn't implemented
|
||||
Missing alert box features
|
||||
--------------------------
|
||||
|
||||
- warn-on-close isn't implemented
|
||||
|
||||
- SessionWindow's dealloc method does nothing yet, so leaks memory
|
||||
Missing input features
|
||||
----------------------
|
||||
|
||||
- use of Alt+numberpad to enter arbitrary numeric character codes
|
||||
is not yet supported
|
||||
|
||||
- cut and paste isn't supported
|
||||
|
||||
- there's no Meta key yet. (I think it will have to be Command
|
||||
rather than Option since the latter is necessary to send some
|
||||
characters, including the rather important # on Apple UK
|
||||
keyboards; but trapping Command-<key> and sending it to the
|
||||
window rather than the application menu requires me to make a
|
||||
positive effort of some sort and I haven't got round to it yet.)
|
||||
- there's no Meta key yet. (I'd like to at least have the
|
||||
possibility of using Command rather than Option as the Meta key,
|
||||
since the latter is necessary to send some characters, including
|
||||
the rather important # on Apple UK keyboards; but trapping
|
||||
Command-<key> and sending it to the window rather than the
|
||||
application menu requires me to make a positive effort of some
|
||||
sort and I haven't got round to it yet. For those Mac users who
|
||||
consider their Command key sacrosanct, don't worry, this option
|
||||
_will_ be configurable and _will_ be off by default.)
|
||||
|
||||
- there's no specials menu
|
||||
|
||||
Missing terminal emulation features
|
||||
-----------------------------------
|
||||
|
||||
- currently no support for server-side window management requests
|
||||
(i.e. escape sequences to minimise or maximise the window,
|
||||
request or change its position and size, change its title etc)
|
||||
|
||||
- window title is currently fixed
|
||||
|
||||
Other missing features
|
||||
----------------------
|
||||
|
||||
- SessionWindow's dealloc method does nothing yet, so leaks memory
|
||||
|
||||
- no Event Log
|
||||
|
||||
- no mid-session Change Settings
|
||||
|
@ -47,6 +47,7 @@ struct alert_queue {
|
||||
void *ldisc;
|
||||
Backend *back;
|
||||
void *backhandle;
|
||||
int exited;
|
||||
/*
|
||||
* The following two members relate to the currently active
|
||||
* alert sheet, if any. They are NULL if there isn't one.
|
||||
@ -65,6 +66,8 @@ struct alert_queue {
|
||||
- (int)fromBackend:(const char *)data len:(int)len isStderr:(int)is_stderr;
|
||||
- (void)startAlert:(NSAlert *)alert
|
||||
withCallback:(void (*)(void *, int))callback andCtx:(void *)ctx;
|
||||
- (void)endSession:(int)clean;
|
||||
- (void)notifyRemoteExit;
|
||||
@end
|
||||
|
||||
/*
|
||||
|
@ -485,7 +485,27 @@ void old_keyfile_warning(void)
|
||||
*/
|
||||
}
|
||||
|
||||
void about_box(void *window)
|
||||
static void connection_fatal_callback(void *ctx, int result)
|
||||
{
|
||||
/* FIXME */
|
||||
SessionWindow *win = (SessionWindow *)ctx;
|
||||
|
||||
[win endSession:FALSE];
|
||||
}
|
||||
|
||||
void connection_fatal(void *frontend, char *p, ...)
|
||||
{
|
||||
SessionWindow *win = (SessionWindow *)frontend;
|
||||
va_list ap;
|
||||
char *msg;
|
||||
NSAlert *alert;
|
||||
|
||||
va_start(ap, p);
|
||||
msg = dupvprintf(p, ap);
|
||||
va_end(ap);
|
||||
|
||||
alert = [[NSAlert alloc] init];
|
||||
[alert setInformativeText:[NSString stringWithCString:msg]];
|
||||
[alert addButtonWithTitle:@"Proceed"];
|
||||
[win startAlert:alert withCallback:connection_fatal_callback
|
||||
andCtx:win];
|
||||
}
|
||||
|
@ -60,28 +60,47 @@ char *x_get_default(const char *key)
|
||||
return NULL; /* this is a stub */
|
||||
}
|
||||
|
||||
void modalfatalbox(char *p, ...)
|
||||
static void commonfatalbox(char *p, va_list ap)
|
||||
{
|
||||
/* FIXME: proper OS X GUI stuff */
|
||||
va_list ap;
|
||||
fprintf(stderr, "FATAL ERROR: ");
|
||||
va_start(ap, p);
|
||||
vfprintf(stderr, p, ap);
|
||||
va_end(ap);
|
||||
fputc('\n', stderr);
|
||||
char errorbuf[2048];
|
||||
NSAlert *alert;
|
||||
|
||||
/*
|
||||
* We may have come here because we ran out of memory, in which
|
||||
* case it's entirely likely that that further memory
|
||||
* allocations will fail. So (a) we use vsnprintf to format the
|
||||
* error message rather than the usual dupvprintf; and (b) we
|
||||
* have a fallback way to get the message out via stderr if
|
||||
* even creating an NSAlert fails.
|
||||
*/
|
||||
vsnprintf(errorbuf, lenof(errorbuf), p, ap);
|
||||
|
||||
alert = [NSAlert alloc];
|
||||
if (!alert) {
|
||||
fprintf(stderr, "fatal error (and NSAlert failed): %s\n", errorbuf);
|
||||
} else {
|
||||
alert = [[alert init] autorelease];
|
||||
[alert addButtonWithTitle:@"Terminate"];
|
||||
[alert setInformativeText:[NSString stringWithCString:errorbuf]];
|
||||
[alert runModal];
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void fatalbox(char *p, ...)
|
||||
{
|
||||
/* FIXME: proper OS X GUI stuff */
|
||||
va_list ap;
|
||||
fprintf(stderr, "FATAL ERROR: ");
|
||||
va_start(ap, p);
|
||||
vfprintf(stderr, p, ap);
|
||||
commonfatalbox(p, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void modalfatalbox(char *p, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, p);
|
||||
commonfatalbox(p, ap);
|
||||
va_end(ap);
|
||||
fputc('\n', stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void cmdline_error(char *p, ...)
|
||||
|
@ -300,6 +300,8 @@
|
||||
*/
|
||||
[self center]; /* :-) */
|
||||
|
||||
exited = FALSE;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -311,6 +313,14 @@
|
||||
* Do so.
|
||||
*/
|
||||
sfree(alert_ctx);
|
||||
if (term)
|
||||
term_free(term);
|
||||
if (logctx)
|
||||
log_free(logctx);
|
||||
if (back)
|
||||
back->free(backhandle);
|
||||
if (ldisc)
|
||||
ldisc_free(ldisc);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@ -346,7 +356,7 @@
|
||||
char coutput[32];
|
||||
int use_coutput = FALSE, special = FALSE, start, end;
|
||||
|
||||
printf("n=%d c=U+%04x cm=U+%04x m=%08x\n", n, c, cm, m);
|
||||
//printf("n=%d c=U+%04x cm=U+%04x m=%08x\n", n, c, cm, m);
|
||||
|
||||
/*
|
||||
* FIXME: Alt+numberpad codes.
|
||||
@ -846,6 +856,33 @@ printf("n=%d c=U+%04x cm=U+%04x m=%08x\n", n, c, cm, m);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)notifyRemoteExit
|
||||
{
|
||||
int exitcode;
|
||||
|
||||
if (!exited && (exitcode = back->exitcode(backhandle)) >= 0)
|
||||
[self endSession:(exitcode == 0)];
|
||||
}
|
||||
|
||||
- (void)endSession:(int)clean
|
||||
{
|
||||
exited = TRUE;
|
||||
if (ldisc) {
|
||||
ldisc_free(ldisc);
|
||||
ldisc = NULL;
|
||||
}
|
||||
if (back) {
|
||||
back->free(backhandle);
|
||||
backhandle = NULL;
|
||||
back = NULL;
|
||||
//FIXME: update specials menu;
|
||||
}
|
||||
if (cfg.close_on_exit == FORCE_ON ||
|
||||
(cfg.close_on_exit == AUTO && clean))
|
||||
[self close];
|
||||
// FIXME: else show restart menu item
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
int from_backend(void *frontend, int is_stderr, const char *data, int len)
|
||||
@ -859,23 +896,11 @@ void frontend_keypress(void *handle)
|
||||
/* FIXME */
|
||||
}
|
||||
|
||||
void connection_fatal(void *frontend, char *p, ...)
|
||||
{
|
||||
//SessionWindow *win = (SessionWindow *)frontend;
|
||||
/* FIXME: proper OS X GUI stuff */
|
||||
va_list ap;
|
||||
fprintf(stderr, "FATAL ERROR: ");
|
||||
va_start(ap, p);
|
||||
vfprintf(stderr, p, ap);
|
||||
va_end(ap);
|
||||
fputc('\n', stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void notify_remote_exit(void *frontend)
|
||||
{
|
||||
//SessionWindow *win = (SessionWindow *)frontend;
|
||||
/* FIXME */
|
||||
SessionWindow *win = (SessionWindow *)frontend;
|
||||
|
||||
[win notifyRemoteExit];
|
||||
}
|
||||
|
||||
void ldisc_update(void *frontend, int echo, int edit)
|
||||
|
Loading…
Reference in New Issue
Block a user