Next patch will need to call on a pane very late, to get it
to free ->data. So we need the handle to persist to the very end.
This means we need a new DAMAGED_DEAD to be set after 'Close' to ensure
nothing else gets called on the pane in the interim.
Signed-off-by: NeilBrown <neil@brown.name>
while (ei->freelist) {
struct pane *p = ei->freelist;
ei->freelist = p->focus;
+ command_put(p->handle);
+ p->handle = NULL;
attr_free(&p->attrs);
free(p);
}
{
struct ed_info *ei = ed->data;
if (!ei) {
+ command_put(p->handle);
+ p->handle = NULL;
attr_free(&p->attrs);
free(p);
return;
while (p) {
int ret = 0;
- if (p->handle) {
+ if (p->handle && !(p->damaged & DAMAGED_DEAD)) {
vci->home = p;
vci->comm = p->handle;
ret = p->handle->func(ci);
* ->parent in place so a full range of commands are available.
*/
// p->parent = p;
- command_put(p->handle);
- p->handle = NULL;
+ p->damaged |= DAMAGED_DEAD;
if (ed != p)
editor_delayed_free(ed, p);
else {
+ command_put(p->handle);
+ p->handle = NULL;
attr_free(&p->attrs);
free(p);
}
#include <limits.h>
#include <sys/stat.h>
#include <stdlib.h>
-
#include "safe.h"
#include "list.h"
DAMAGED_POSTORDER= 512,
DAMAGED_CLOSED = 1024,
+ DAMAGED_DEAD = 2048, /* Fully closed, but not freed yet */
};
#define DAMAGED_NEED_CALL (DAMAGED_SIZE | DAMAGED_CONTENT | DAMAGED_CURSOR)
ret = key_handle(&ci);
break;
case TYPE_pane:
- if (!home->handle)
+ if (!home->handle || (home->damaged & DAMAGED_DEAD))
return Efail;
ci.comm = home->handle;
ret = ci.comm->func(&ci);