aboutsummaryrefslogtreecommitdiff
path: root/window.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2017-04-28 22:01:18 +0100
committerThomas Adam <thomas@xteddy.org>2017-04-28 22:01:18 +0100
commit3a8e56b282161ab4feb728bfedba77aa35093a0a (patch)
treeac58d53220819d892f1e8177a7cf63ffddac6907 /window.c
parent36202a63e979f41943003d49748eaebe5776bf7f (diff)
parent0f2f783584c62879a1182972e915f550bf23f00a (diff)
downloadrtmux-3a8e56b282161ab4feb728bfedba77aa35093a0a.tar.gz
rtmux-3a8e56b282161ab4feb728bfedba77aa35093a0a.tar.bz2
rtmux-3a8e56b282161ab4feb728bfedba77aa35093a0a.zip
Merge branch 'obsd-master'
Diffstat (limited to 'window.c')
-rw-r--r--window.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/window.c b/window.c
index 4aaee3a6..ed73050e 100644
--- a/window.c
+++ b/window.c
@@ -186,11 +186,11 @@ winlink_set_window(struct winlink *wl, struct window *w)
{
if (wl->window != NULL) {
TAILQ_REMOVE(&wl->window->winlinks, wl, wentry);
- window_remove_ref(w);
+ window_remove_ref(wl->window, __func__);
}
TAILQ_INSERT_TAIL(&w->winlinks, wl, wentry);
wl->window = w;
- w->references++;
+ window_add_ref(w, __func__);
}
void
@@ -200,7 +200,7 @@ winlink_remove(struct winlinks *wwl, struct winlink *wl)
if (w != NULL) {
TAILQ_REMOVE(&w->winlinks, wl, wentry);
- window_remove_ref(w);
+ window_remove_ref(w, __func__);
}
RB_REMOVE(winlinks, wwl, wl);
@@ -361,8 +361,7 @@ window_create_spawn(const char *name, int argc, char **argv, const char *path,
static void
window_destroy(struct window *w)
{
- if (!TAILQ_EMPTY(&w->winlinks))
- fatalx("window destroyed with winlinks");
+ log_debug("window @%u destroyed (%d references)", w->id, w->references);
RB_REMOVE(windows, &windows, w);
@@ -387,11 +386,18 @@ window_destroy(struct window *w)
}
void
-window_remove_ref(struct window *w)
+window_add_ref(struct window *w, const char *from)
+{
+ w->references++;
+ log_debug("%s: @%u %s, now %d", __func__, w->id, from, w->references);
+}
+
+void
+window_remove_ref(struct window *w, const char *from)
{
- if (w->references == 0)
- fatal("bad reference count");
w->references--;
+ log_debug("%s: @%u %s, now %d", __func__, w->id, from, w->references);
+
if (w->references == 0)
window_destroy(w);
}