Need to set clients in context before changing their reference count.

pull/1/head
Nicholas Marriott 2013-03-22 15:54:29 +00:00
parent d644e5143f
commit 2243cfbe75
8 changed files with 15 additions and 18 deletions

2
cfg.c
View File

@ -92,7 +92,7 @@ load_cfg(const char *path, struct cmd_ctx *ctx, struct causelist *causes)
if (ctx != NULL)
cmd_ref_ctx(ctx);
else {
ctx = cmd_get_ctx();
ctx = cmd_get_ctx(NULL, NULL);
ctx->error = cfg_error;
ctx->print = cfg_print;
ctx->info = cfg_print;

View File

@ -184,8 +184,7 @@ cmd_command_prompt_callback(void *data, const char *s)
return (0);
}
ctx = cmd_get_ctx();
ctx->curclient = c;
ctx = cmd_get_ctx(NULL, c);
ctx->error = key_bindings_error;
ctx->print = key_bindings_print;
ctx->info = key_bindings_info;

View File

@ -125,8 +125,7 @@ cmd_confirm_before_callback(void *data, const char *s)
return (0);
}
ctx = cmd_get_ctx();
ctx->curclient = c;
ctx = cmd_get_ctx(NULL, c);
ctx->error = key_bindings_error;
ctx->print = key_bindings_print;
ctx->info = key_bindings_info;

5
cmd.c
View File

@ -134,13 +134,16 @@ int cmd_find_index_offset(const char *, struct session *, int *);
struct window_pane *cmd_find_pane_offset(const char *, struct winlink *);
struct cmd_ctx *
cmd_get_ctx(void)
cmd_get_ctx(struct client *cmdclient, struct client *curclient)
{
struct cmd_ctx *ctx;
ctx = xcalloc(1, sizeof *ctx);
ctx->references = 0;
ctx->cmdclient = cmdclient;
ctx->curclient = curclient;
cmd_ref_ctx(ctx);
return (ctx);
}

View File

@ -108,8 +108,7 @@ control_callback(struct client *c, int closed, unused void *data)
break;
}
ctx = cmd_get_ctx();
ctx->curclient = c;
ctx = cmd_get_ctx(NULL, c);
ctx->error = control_msg_error;
ctx->print = control_msg_print;
ctx->info = control_msg_info;

View File

@ -266,8 +266,7 @@ key_bindings_dispatch(struct key_binding *bd, struct client *c)
struct cmd *cmd;
int readonly;
ctx = cmd_get_ctx();
ctx->curclient = c;
ctx = cmd_get_ctx(NULL, c);
ctx->error = key_bindings_error;
ctx->print = key_bindings_print;
ctx->info = key_bindings_info;

View File

@ -870,9 +870,8 @@ server_client_msg_command(struct client *c, struct msg_command_data *data)
int argc;
char **argv, *cause;
ctx = cmd_get_ctx();
ctx = cmd_get_ctx(c, NULL);
ctx->msgdata = data;
ctx->cmdclient = c;
ctx->error = server_client_msg_error;
ctx->print = server_client_msg_print;
ctx->info = server_client_msg_info;

View File

@ -220,8 +220,7 @@ window_choose_data_run(struct window_choose_data *cdata)
return;
}
ctx = cmd_get_ctx();
ctx->curclient = cdata->start_client;
ctx = cmd_get_ctx(NULL, cdata->start_client);
ctx->error = key_bindings_error;
ctx->print = key_bindings_print;
ctx->info = key_bindings_info;
@ -492,7 +491,7 @@ window_choose_key(struct window_pane *wp, unused struct session *sess, int key)
items = ARRAY_LENGTH(&data->list);
if (data->input_type == WINDOW_CHOOSE_GOTO_ITEM) {
switch (mode_key_lookup(&data->mdata, key)) {
switch (mode_key_lookup(&data->mdata, key, NULL)) {
case MODEKEYCHOICE_CANCEL:
data->input_type = WINDOW_CHOOSE_NORMAL;
window_choose_redraw_screen(wp);
@ -523,7 +522,7 @@ window_choose_key(struct window_pane *wp, unused struct session *sess, int key)
return;
}
switch (mode_key_lookup(&data->mdata, key)) {
switch (mode_key_lookup(&data->mdata, key, NULL)) {
case MODEKEYCHOICE_CANCEL:
window_choose_fire_callback(wp, NULL);
break;
@ -777,7 +776,7 @@ window_choose_key_index(struct window_choose_mode_data *data, u_int idx)
int mkey;
for (ptr = keys; *ptr != '\0'; ptr++) {
mkey = mode_key_lookup(&data->mdata, *ptr);
mkey = mode_key_lookup(&data->mdata, *ptr, NULL);
if (mkey != MODEKEY_NONE && mkey != MODEKEY_OTHER)
continue;
if (idx-- == 0)
@ -797,7 +796,7 @@ window_choose_index_key(struct window_choose_mode_data *data, int key)
u_int idx = 0;
for (ptr = keys; *ptr != '\0'; ptr++) {
mkey = mode_key_lookup(&data->mdata, *ptr);
mkey = mode_key_lookup(&data->mdata, *ptr, NULL);
if (mkey != MODEKEY_NONE && mkey != MODEKEY_OTHER)
continue;
if (key == *ptr)