From 9b0f88f0242d60e037121bc1f8301c5bb0b4de65 Mon Sep 17 00:00:00 2001 From: nick black Date: Thu, 17 Dec 2020 15:02:49 -0500 Subject: [PATCH] ncpile_drop(): reset stdplane's blist #1226 --- src/lib/notcurses.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 9b183d46e..5c1af4b90 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -1187,16 +1187,25 @@ err: // updates *pile to point at (*pile)->next, frees all but standard pile/plane static void ncpile_drop(notcurses* nc, ncpile** pile){ + bool sawstdplane = false; ncpile* next = (*pile)->next; ncplane* p = (*pile)->top; while(p){ ncplane* tmp = p->below; if(nc->stdplane != p){ free_plane(p); + }else{ + sawstdplane = true; } p = tmp; } *pile = next; + if(sawstdplane){ + ncplane_pile(nc->stdplane)->top = nc->stdplane; + ncplane_pile(nc->stdplane)->bottom = nc->stdplane; + nc->stdplane->above = nc->stdplane->below = NULL; + nc->stdplane->blist = NULL; + } } // drop all piles and all planes, save the standard plane and its pile @@ -1208,9 +1217,6 @@ void notcurses_drop_planes(notcurses* nc){ ncpile_drop(nc, &p); }while(p0 != p); pthread_mutex_unlock(&nc->pilelock); - ncplane_pile(nc->stdplane)->top = nc->stdplane; - ncplane_pile(nc->stdplane)->bottom = nc->stdplane; - nc->stdplane->above = nc->stdplane->below = NULL; } int notcurses_stop(notcurses* nc){