From: NeilBrown Date: Mon, 25 Jan 2016 02:32:27 +0000 (+1100) Subject: doc: track whether view is active X-Git-Tag: lca2016~13 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=de1cd84a5b5804d6c7b8e52545f3ad882100d045;p=edlib.git doc: track whether view is active Previously we use the presense of 'notify' to see if a view is active. I am deprecating 'notify', no record that information in 'state' (shared with 'marked'). Signed-off-by: NeilBrown --- diff --git a/core-doc.c b/core-doc.c index df735862..0148730a 100644 --- a/core-doc.c +++ b/core-doc.c @@ -51,12 +51,12 @@ static int do_doc_add_view(struct doc *d, struct command *c) tlist_add(&g[i].head, GRP_HEAD, &d->views[i].head); tlist_del(&d->views[i].head); g[i].notify = d->views[i].notify; - g[i].marked = d->views[i].marked; + g[i].state = d->views[i].state; } for (; i < d->nviews; i++) { INIT_TLIST_HEAD(&g[i].head, GRP_HEAD); g[i].notify = NULL; - g[i].marked = 0; + g[i].state = 0; } free(d->views); d->views = g; @@ -65,7 +65,7 @@ static int do_doc_add_view(struct doc *d, struct command *c) } points_attach(d, ret); d->views[ret].notify = c; - d->views[ret].marked = 0; + d->views[ret].state = 1; return ret; } @@ -81,6 +81,7 @@ static void do_doc_del_view(struct doc *d, struct command *c) if (i >= d->nviews) return; d->views[i].notify = NULL; + d->views[i].state = 0; while (!tlist_empty(&d->views[i].head)) { struct tlist_head *tl = d->views[i].head.next; if (TLIST_TYPE(tl) != GRP_LIST) @@ -104,14 +105,13 @@ static void doc_close_views(struct doc *d) int i; for (i = 0; i < d->nviews; i++) - if (d->views[i].notify) - d->views[i].marked = 1; - else - d->views[i].marked = 0; + if (d->views[i].state) + /* mark as being deleted */ + d->views[i].state = 2; ci.key = "Release"; for (i = 0; i < d->nviews; i++) { struct command *c; - if (!d->views[i].marked) + if (d->views[i].state != 2) /* Don't delete newly added views */ continue; if (d->views[i].notify == NULL) diff --git a/core.h b/core.h index 76cdabb5..e957b937 100644 --- a/core.h +++ b/core.h @@ -96,7 +96,7 @@ struct doc { struct docview { struct tlist_head head; struct command *notify; - short marked; /* being deleted */ + short state; /* 0 = unused, 1 = active, 2 = being deleted */ } *views; struct attrset *attrs; int nviews;