version 1.191, 2017/04/28 19:12:15 |
version 1.192, 2017/04/28 19:13:55 |
|
|
{ |
{ |
if (wl->window != NULL) { |
if (wl->window != NULL) { |
TAILQ_REMOVE(&wl->window->winlinks, wl, wentry); |
TAILQ_REMOVE(&wl->window->winlinks, wl, wentry); |
window_remove_ref(wl->window); |
window_remove_ref(wl->window, __func__); |
} |
} |
TAILQ_INSERT_TAIL(&w->winlinks, wl, wentry); |
TAILQ_INSERT_TAIL(&w->winlinks, wl, wentry); |
wl->window = w; |
wl->window = w; |
w->references++; |
window_add_ref(w, __func__); |
} |
} |
|
|
void |
void |
|
|
|
|
if (w != NULL) { |
if (w != NULL) { |
TAILQ_REMOVE(&w->winlinks, wl, wentry); |
TAILQ_REMOVE(&w->winlinks, wl, wentry); |
window_remove_ref(w); |
window_remove_ref(w, __func__); |
} |
} |
|
|
RB_REMOVE(winlinks, wwl, wl); |
RB_REMOVE(winlinks, wwl, wl); |
|
|
static void |
static void |
window_destroy(struct window *w) |
window_destroy(struct window *w) |
{ |
{ |
if (!TAILQ_EMPTY(&w->winlinks)) |
log_debug("window @%u destroyed (%d references)", w->id, w->references); |
fatalx("window destroyed with winlinks"); |
|
|
|
RB_REMOVE(windows, &windows, w); |
RB_REMOVE(windows, &windows, w); |
|
|
|
|
} |
} |
|
|
void |
void |
window_remove_ref(struct window *w) |
window_add_ref(struct window *w, const char *from) |
{ |
{ |
if (w->references == 0) |
w->references++; |
fatal("bad reference count"); |
log_debug("%s: @%u %s, now %d", __func__, w->id, from, w->references); |
|
} |
|
|
|
void |
|
window_remove_ref(struct window *w, const char *from) |
|
{ |
w->references--; |
w->references--; |
|
log_debug("%s: @%u %s, now %d", __func__, w->id, from, w->references); |
|
|
if (w->references == 0) |
if (w->references == 0) |
window_destroy(w); |
window_destroy(w); |
} |
} |