From: NeilBrown Date: Sun, 3 Sep 2023 09:24:23 +0000 (+1000) Subject: Don't call "Close" on panes that haven't been initialised. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=82f1e2125ee6582216654f4e6927944f921fbf59;p=edlib.git Don't call "Close" on panes that haven't been initialised. If the Child-Notify call fails we discard the pane. But calling "Close" will call code that expect the pane.data to be initialised. It won't be. So add a DAMAGED flag to allow this call to be skipped. Signed-off-by: NeilBrown --- diff --git a/core-pane.c b/core-pane.c index 5957054f..c39848e2 100644 --- a/core-pane.c +++ b/core-pane.c @@ -174,6 +174,7 @@ static struct pane *_do_pane_register(struct pane *parent, short z, if (pane_call(parent, "Child-Notify", p, 1) < 0 || p->damaged & DAMAGED_CLOSED) { /* ChildRegistered objected */ + p->damaged |= DAMAGED_NOINIT; pane_close(p); p = NULL; } else @@ -614,7 +615,8 @@ void pane_close(struct pane *p safe) p->parent->focus == p) pane_refocus(p->parent); - pane_call(p, "Close", p, infocus); + if (!(p->damaged & DAMAGED_NOINIT)) + pane_call(p, "Close", p, infocus); /* If a child has not yet had "Close" called, we need to leave * ->parent in place so a full range of commands are available. diff --git a/core.h b/core.h index 43ff81a7..119a5a15 100644 --- a/core.h +++ b/core.h @@ -438,6 +438,9 @@ enum { * hasn't been handled yet. */ DAMAGED_DEBUG = BIT(12), + DAMAGED_NOINIT = BIT(11), /* Closing before pane_register + * had a chance to complete. + */ }; #define DAMAGED_NEED_CALL (DAMAGED_SIZE | DAMAGED_REFRESH)