From: NeilBrown Date: Fri, 11 Dec 2015 02:44:32 +0000 (+1100) Subject: popup: Close doc more directly. X-Git-Tag: lca2016~61 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=773125d6030b8238c2f37529cba76459c5e5bb65;p=edlib.git popup: Close doc more directly. I want this to all go eventually with auto-close documents. But destroying a doc via some pane is problematic as the pane might have disappeared already. So do it more directly. Signed-off-by: NeilBrown --- diff --git a/lib-popup.c b/lib-popup.c index 836b5cc9..6831ae31 100644 --- a/lib-popup.c +++ b/lib-popup.c @@ -63,13 +63,22 @@ DEF_CMD(popup_handle) struct popup_info *ppi = p->data; if (strcmp(ci->key, "Close") == 0) { + if (ppi->doc) + /* FIXME make this doc auto-close */ + doc_destroy(ppi->doc->home); free(ppi); return 1; } if (strcmp(ci->key, "Notify:Close") == 0) { - if (ci->focus == ppi->target) + if (ci->focus == ppi->target) { + if (ppi->doc) { + /* FIXME make this doc auto-close */ + doc_destroy(ppi->doc->home); + ppi->doc = NULL; + } pane_close(p); + } return 1; } @@ -82,8 +91,8 @@ DEF_CMD(popup_handle) call3("Abort", ppi->target, 0, NULL); if (ppi->doc) { /* FIXME make this doc auto-close */ + doc_destroy(ppi->doc->home); ppi->doc = NULL; - doc_destroy(ci->focus); } pane_close(ppi->popup); return 1; @@ -106,8 +115,8 @@ DEF_CMD(popup_handle) free(ci2.str); if (ppi->doc) { /* FIXME make this doc auto-close */ + doc_destroy(ppi->doc->home); ppi->doc = NULL; - doc_destroy(ci->focus); } pane_close(ppi->popup); return 1;