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

This commit is contained in:
Nicholas Marriott 2013-02-20 10:25:15 +00:00
parent e68b9abd04
commit afd5e978cf
9 changed files with 12 additions and 15 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

@ -133,13 +133,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

@ -869,9 +869,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;

2
tmux.h
View File

@ -1714,7 +1714,7 @@ long long args_strtonum(
struct args *, u_char, long long, long long, char **);
/* cmd.c */
struct cmd_ctx *cmd_get_ctx(void);
struct cmd_ctx *cmd_get_ctx(struct client *, struct client *);
void cmd_free_ctx(struct cmd_ctx *);
void cmd_ref_ctx(struct cmd_ctx *);
int cmd_pack_argv(int, char **, char *, size_t);

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;