From: owen Date: Tue, 15 Mar 2005 10:43:29 +0000 (+0000) Subject: Fix pterm-logtype-crash X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/commitdiff_plain/1755669275bbd8a9d3cefb9433e638d9f8b7eda9 Fix pterm-logtype-crash git-svn-id: svn://svn.tartarus.org/sgt/putty@5505 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/config.c b/config.c index 0f712019..5922e041 100644 --- a/config.c +++ b/config.c @@ -50,6 +50,33 @@ static void protocolbuttons_handler(union control *ctrl, void *dlg, } } +static void loggingbuttons_handler(union control *ctrl, void *dlg, + void *data, int event) +{ + int button; + Config *cfg = (Config *)data; + /* This function works just like the standard radio-button handler, + * but it has to fall back to "no logging" in situations where the + * configured logging type isn't applicable. + */ + if (event == EVENT_REFRESH) { + for (button = 0; button < ctrl->radio.nbuttons; button++) + if (cfg->logtype == ctrl->radio.buttondata[button].i) + break; + + /* We fell off the end, so we lack the configured logging type */ + if (button == ctrl->radio.nbuttons) { + button=0; + cfg->logtype=LGTYP_NONE; + } + dlg_radiobutton_set(ctrl, dlg, button); + } else if (event == EVENT_VALCHANGE) { + button = dlg_radiobutton_get(ctrl, dlg); + assert(button >= 0 && button < ctrl->radio.nbuttons); + cfg->logtype = ctrl->radio.buttondata[button].i; + } +} + static void numeric_keypad_handler(union control *ctrl, void *dlg, void *data, int event) { @@ -947,7 +974,7 @@ void setup_config_box(struct controlbox *b, struct sesslist *sesslist, sshlogname = NULL; /* this will disable the button */ ctrl_radiobuttons(s, "Session logging:", NO_SHORTCUT, 1, HELPCTX(logging_main), - dlg_stdradiobutton_handler, + loggingbuttons_handler, I(offsetof(Config, logtype)), "Logging turned off completely", 't', I(LGTYP_NONE), "Log printable output only", 'p', I(LGTYP_ASCII),