mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-26 09:42:25 +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:
|
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
|
- terminal display is horribly slow
|
||||||
wrong for a GUI application
|
|
||||||
|
|
||||||
- fonts aren't configurable
|
- 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
|
starting position, plus remembering previous window positions per
|
||||||
the Apple HIG) is not implemented
|
the Apple HIG) is not implemented
|
||||||
|
|
||||||
- close-on-exit isn't implemented
|
Missing alert box features
|
||||||
|
--------------------------
|
||||||
|
|
||||||
- warn-on-close isn't implemented
|
- 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
|
- use of Alt+numberpad to enter arbitrary numeric character codes
|
||||||
is not yet supported
|
is not yet supported
|
||||||
|
|
||||||
- cut and paste isn't supported
|
- cut and paste isn't supported
|
||||||
|
|
||||||
- there's no Meta key yet. (I think it will have to be Command
|
- there's no Meta key yet. (I'd like to at least have the
|
||||||
rather than Option since the latter is necessary to send some
|
possibility of using Command rather than Option as the Meta key,
|
||||||
characters, including the rather important # on Apple UK
|
since the latter is necessary to send some characters, including
|
||||||
keyboards; but trapping Command-<key> and sending it to the
|
the rather important # on Apple UK keyboards; but trapping
|
||||||
window rather than the application menu requires me to make a
|
Command-<key> and sending it to the window rather than the
|
||||||
positive effort of some sort and I haven't got round to it yet.)
|
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
|
- there's no specials menu
|
||||||
|
|
||||||
|
Missing terminal emulation features
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
- currently no support for server-side window management requests
|
- currently no support for server-side window management requests
|
||||||
(i.e. escape sequences to minimise or maximise the window,
|
(i.e. escape sequences to minimise or maximise the window,
|
||||||
request or change its position and size, change its title etc)
|
request or change its position and size, change its title etc)
|
||||||
|
|
||||||
- window title is currently fixed
|
- window title is currently fixed
|
||||||
|
|
||||||
|
Other missing features
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
- SessionWindow's dealloc method does nothing yet, so leaks memory
|
||||||
|
|
||||||
- no Event Log
|
- no Event Log
|
||||||
|
|
||||||
- no mid-session Change Settings
|
- no mid-session Change Settings
|
||||||
|
@ -47,6 +47,7 @@ struct alert_queue {
|
|||||||
void *ldisc;
|
void *ldisc;
|
||||||
Backend *back;
|
Backend *back;
|
||||||
void *backhandle;
|
void *backhandle;
|
||||||
|
int exited;
|
||||||
/*
|
/*
|
||||||
* The following two members relate to the currently active
|
* The following two members relate to the currently active
|
||||||
* alert sheet, if any. They are NULL if there isn't one.
|
* 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;
|
- (int)fromBackend:(const char *)data len:(int)len isStderr:(int)is_stderr;
|
||||||
- (void)startAlert:(NSAlert *)alert
|
- (void)startAlert:(NSAlert *)alert
|
||||||
withCallback:(void (*)(void *, int))callback andCtx:(void *)ctx;
|
withCallback:(void (*)(void *, int))callback andCtx:(void *)ctx;
|
||||||
|
- (void)endSession:(int)clean;
|
||||||
|
- (void)notifyRemoteExit;
|
||||||
@end
|
@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 */
|
return NULL; /* this is a stub */
|
||||||
}
|
}
|
||||||
|
|
||||||
void modalfatalbox(char *p, ...)
|
static void commonfatalbox(char *p, va_list ap)
|
||||||
{
|
{
|
||||||
/* FIXME: proper OS X GUI stuff */
|
char errorbuf[2048];
|
||||||
va_list ap;
|
NSAlert *alert;
|
||||||
fprintf(stderr, "FATAL ERROR: ");
|
|
||||||
va_start(ap, p);
|
/*
|
||||||
vfprintf(stderr, p, ap);
|
* We may have come here because we ran out of memory, in which
|
||||||
va_end(ap);
|
* case it's entirely likely that that further memory
|
||||||
fputc('\n', stderr);
|
* 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);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fatalbox(char *p, ...)
|
void fatalbox(char *p, ...)
|
||||||
{
|
{
|
||||||
/* FIXME: proper OS X GUI stuff */
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
fprintf(stderr, "FATAL ERROR: ");
|
|
||||||
va_start(ap, p);
|
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);
|
va_end(ap);
|
||||||
fputc('\n', stderr);
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmdline_error(char *p, ...)
|
void cmdline_error(char *p, ...)
|
||||||
|
@ -300,6 +300,8 @@
|
|||||||
*/
|
*/
|
||||||
[self center]; /* :-) */
|
[self center]; /* :-) */
|
||||||
|
|
||||||
|
exited = FALSE;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,6 +313,14 @@
|
|||||||
* Do so.
|
* Do so.
|
||||||
*/
|
*/
|
||||||
sfree(alert_ctx);
|
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];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,7 +356,7 @@
|
|||||||
char coutput[32];
|
char coutput[32];
|
||||||
int use_coutput = FALSE, special = FALSE, start, end;
|
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.
|
* 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
|
@end
|
||||||
|
|
||||||
int from_backend(void *frontend, int is_stderr, const char *data, int len)
|
int from_backend(void *frontend, int is_stderr, const char *data, int len)
|
||||||
@ -859,23 +896,11 @@ void frontend_keypress(void *handle)
|
|||||||
/* FIXME */
|
/* 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)
|
void notify_remote_exit(void *frontend)
|
||||||
{
|
{
|
||||||
//SessionWindow *win = (SessionWindow *)frontend;
|
SessionWindow *win = (SessionWindow *)frontend;
|
||||||
/* FIXME */
|
|
||||||
|
[win notifyRemoteExit];
|
||||||
}
|
}
|
||||||
|
|
||||||
void ldisc_update(void *frontend, int echo, int edit)
|
void ldisc_update(void *frontend, int echo, int edit)
|
||||||
|
Loading…
Reference in New Issue
Block a user