diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-11-01 23:20:38 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-11-01 23:20:38 +0000 |
commit | 02c10b77cdec682bc2c059683b30656cd6348531 (patch) | |
tree | 66d313cd009e9316bb2ecf36b503604de91bd2ef /usr.bin/tmux/cmd-set-option.c | |
parent | c412fabe01785366debb0e53069d3ce9fdb89b6f (diff) |
Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.
Fixes problems with changing options from inside #().
Diffstat (limited to 'usr.bin/tmux/cmd-set-option.c')
-rw-r--r-- | usr.bin/tmux/cmd-set-option.c | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/usr.bin/tmux/cmd-set-option.c b/usr.bin/tmux/cmd-set-option.c index 4dd1ee6fb0d..7cf2ca7ef2f 100644 --- a/usr.bin/tmux/cmd-set-option.c +++ b/usr.bin/tmux/cmd-set-option.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-set-option.c,v 1.23 2009/10/10 15:03:01 nicm Exp $ */ +/* $OpenBSD: cmd-set-option.c,v 1.24 2009/11/01 23:20:37 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -108,7 +108,10 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx) struct client *c; struct options *oo; const struct set_option_entry *entry, *opt; + struct jobs *jobs; + struct job *job, *nextjob; u_int i; + int try_again; if (data->chflags & CMD_CHFLAG('g')) oo = &global_s_options; @@ -184,11 +187,34 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx) } recalculate_sizes(); - for (i = 0; i < ARRAY_LENGTH(&clients); i++) { - c = ARRAY_ITEM(&clients, i); - if (c != NULL && c->session != NULL) { - job_tree_free(&c->status_jobs); - job_tree_init(&c->status_jobs); + + /* + * Special-case: kill all persistent jobs if status-left, status-right + * or set-titles-string have changed. Persistent jobs are only used by + * the status line at the moment so this works XXX. + */ + if (strcmp(entry->name, "status-left") == 0 || + strcmp(entry->name, "status-right") == 0 || + strcmp(entry->name, "set-titles-string") == 0) { + for (i = 0; i < ARRAY_LENGTH(&clients); i++) { + c = ARRAY_ITEM(&clients, i); + if (c == NULL || c->session == NULL) + continue; + + jobs = &c->status_jobs; + do { + try_again = 0; + job = RB_ROOT(jobs); + while (job != NULL) { + nextjob = RB_NEXT(jobs, jobs, job); + if (job->flags & JOB_PERSIST) { + job_remove(jobs, job); + try_again = 1; + break; + } + job = nextjob; + } + } while (try_again); server_redraw_client(c); } } |