]> git.neil.brown.name Git - edlib.git/commitdiff
popup: Close doc more directly.
authorNeilBrown <neil@brown.name>
Fri, 11 Dec 2015 02:44:32 +0000 (13:44 +1100)
committerNeilBrown <neil@brown.name>
Fri, 11 Dec 2015 02:44:32 +0000 (13:44 +1100)
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 <neil@brown.name>
lib-popup.c

index 836b5cc902d7a7534c970b8ab7ad022ce3bc1a76..6831ae310c375cfad7af5a20e728b3dd49c61bc7 100644 (file)
@@ -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;