=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/window.c,v retrieving revision 1.173 retrieving revision 1.174 diff -u -r1.173 -r1.174 --- src/usr.bin/tmux/window.c 2016/10/18 07:38:16 1.173 +++ src/usr.bin/tmux/window.c 2016/10/19 09:22:07 1.174 @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.173 2016/10/18 07:38:16 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.174 2016/10/19 09:22:07 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -60,6 +60,8 @@ static u_int next_window_id; static u_int next_active_point; +static void window_destroy(struct window *); + static struct window_pane *window_pane_create(struct window *, u_int, u_int, u_int); static void window_pane_destroy(struct window_pane *); @@ -184,6 +186,11 @@ void winlink_set_window(struct winlink *wl, struct window *w) { + if (wl->window != NULL) { + TAILQ_REMOVE(&wl->window->winlinks, wl, wentry); + window_remove_ref(w); + } + TAILQ_INSERT_TAIL(&w->winlinks, wl, wentry); wl->window = w; w->references++; } @@ -193,12 +200,14 @@ { struct window *w = wl->window; + if (w != NULL) { + TAILQ_REMOVE(&w->winlinks, wl, wentry); + window_remove_ref(w); + } + RB_REMOVE(winlinks, wwl, wl); free(wl->status_text); free(wl); - - if (w != NULL) - window_remove_ref(w); } struct winlink * @@ -313,6 +322,7 @@ w->options = options_create(global_w_options); w->references = 0; + TAILQ_INIT(&w->winlinks); w->id = next_window_id++; RB_INSERT(windows, &windows, w); @@ -350,9 +360,12 @@ return (w); } -void +static void window_destroy(struct window *w) { + if (!TAILQ_EMPTY(&w->winlinks)) + fatalx("window destroyed with winlinks"); + RB_REMOVE(windows, &windows, w); if (w->layout_root != NULL) @@ -1421,19 +1434,13 @@ void winlink_clear_flags(struct winlink *wl) { - struct session *s; - struct winlink *wl_loop; + struct winlink *loop; - RB_FOREACH(s, sessions, &sessions) { - RB_FOREACH(wl_loop, winlinks, &s->windows) { - if (wl_loop->window != wl->window) - continue; - if ((wl_loop->flags & WINLINK_ALERTFLAGS) == 0) - continue; - - wl_loop->flags &= ~WINLINK_ALERTFLAGS; - wl_loop->window->flags &= ~WINDOW_ALERTFLAGS; - server_status_session(s); + wl->window->flags &= ~WINDOW_ALERTFLAGS; + TAILQ_FOREACH(loop, &wl->window->winlinks, wentry) { + if ((loop->flags & WINLINK_ALERTFLAGS) != 0) { + loop->flags &= ~WINLINK_ALERTFLAGS; + server_status_session(loop->session); } } }