]> git.neil.brown.name Git - edlib.git/commitdiff
editor: move delayed free of panes to event:on-idle
authorNeilBrown <neil@brown.name>
Fri, 9 Jun 2023 03:18:33 +0000 (13:18 +1000)
committerNeilBrown <neil@brown.name>
Wed, 28 Jun 2023 07:51:40 +0000 (17:51 +1000)
Schedule an on-idle event when we queue the first pane to free, and use
it to free them all.

Signed-off-by: NeilBrown <neil@brown.name>
core-editor.c

index 5889604a080f3986dcd003627daf6a335750c358..a0270d723f735f1d5f523e0c116a8ea47d1c3913 100644 (file)
@@ -293,7 +293,7 @@ DEF_CMD(editor_send_notify)
                                ci->num2, ci->mark2, ci->str2, ci->comm2);
 }
 
-DEF_CMD(editor_clean_up)
+DEF_CMD(editor_free_panes)
 {
        struct ed_info *ei = ci->home->data;
 
@@ -309,6 +309,13 @@ DEF_CMD(editor_clean_up)
                attr_free(&p->attrs);
                pane_put(p);
        }
+       return 1;
+}
+
+DEF_CMD(editor_clean_up)
+{
+       struct ed_info *ei = ci->home->data;
+
        while (ei->mark_free_list) {
                struct mark *m = ei->mark_free_list;
                ei->mark_free_list = (struct mark*)m->all.next;
@@ -431,6 +438,8 @@ void editor_delayed_free(struct pane *ed safe, struct pane *p safe)
                return;
        }
        ASSERT(ei->magic==ED_MAGIC);
+       if (!ei->freelist)
+               call_comm("event:on-idle", ed, &editor_free_panes, 2);
        p->focus = ei->freelist;
        ei->freelist = p;
 }