]> git.neil.brown.name Git - edlib.git/commitdiff
Don't call "Close" on panes that haven't been initialised.
authorNeilBrown <neil@brown.name>
Sun, 3 Sep 2023 09:24:23 +0000 (19:24 +1000)
committerNeilBrown <neil@brown.name>
Mon, 4 Sep 2023 23:07:53 +0000 (09:07 +1000)
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 <neil@brown.name>
core-pane.c
core.h

index 5957054fd24701716c983af0afe861ebf8b4e57c..c39848e27c5a5af90b4e061e35b0355fad324fce 100644 (file)
@@ -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 43ff81a748584dedead3fc10270e1404e2070ad3..119a5a1511eed414fe9c33202ac1eb0dd969a341 100644 (file)
--- 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)