ncplane_reparent: destroy old empty piles #1614

This commit is contained in:
nick black 2021-05-01 16:17:15 -04:00
parent 7c53072803
commit ad4763127e
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

View File

@ -711,6 +711,8 @@ int ncplane_resize_internal(ncplane* n, int keepy, int keepx, int keepleny,
n->lenx = xlen; n->lenx = xlen;
n->leny = ylen; n->leny = ylen;
free(preserved); free(preserved);
/*fprintf(stderr, "RESIZE COMPLETE\n");
notcurses_debug(nc, stderr);*/
return resize_callbacks_children(n); return resize_callbacks_children(n);
} }
@ -2420,13 +2422,13 @@ ncplane* ncplane_reparent_family(ncplane* n, ncplane* newparent){
if(n == n->boundto){ // we're a new root plane if(n == n->boundto){ // we're a new root plane
n->bnext = NULL; n->bnext = NULL;
n->bprev = NULL; n->bprev = NULL;
splice_zaxis_recursive(n);
pthread_mutex_lock(&ncplane_notcurses(n)->pilelock); pthread_mutex_lock(&ncplane_notcurses(n)->pilelock);
if(ncplane_pile(n)->top == NULL){ // did we just empty our pile? if(ncplane_pile(n)->top == NULL){ // did we just empty our pile?
ncpile_destroy(ncplane_pile(n)); ncpile_destroy(ncplane_pile(n));
} }
make_ncpile(ncplane_notcurses(n), n); make_ncpile(ncplane_notcurses(n), n);
pthread_mutex_unlock(&ncplane_notcurses(n)->pilelock); pthread_mutex_unlock(&ncplane_notcurses(n)->pilelock);
splice_zaxis_recursive(n);
}else{ // establish ourselves as a sibling of new parent's children }else{ // establish ourselves as a sibling of new parent's children
if( (n->bnext = newparent->blist) ){ if( (n->bnext = newparent->blist) ){
n->bnext->bprev = &n->bnext; n->bnext->bprev = &n->bnext;
@ -2435,8 +2437,13 @@ ncplane* ncplane_reparent_family(ncplane* n, ncplane* newparent){
newparent->blist = n; newparent->blist = n;
// place it immediately above the new binding plane if crossing piles // place it immediately above the new binding plane if crossing piles
if(n->pile != ncplane_pile(n->boundto)){ if(n->pile != ncplane_pile(n->boundto)){
n->pile = ncplane_pile(n->boundto);
splice_zaxis_recursive(n); splice_zaxis_recursive(n);
pthread_mutex_lock(&ncplane_notcurses(n)->pilelock);
if(ncplane_pile(n)->top == NULL){ // did we just empty our pile?
ncpile_destroy(ncplane_pile(n));
}
pthread_mutex_unlock(&ncplane_notcurses(n)->pilelock);
n->pile = ncplane_pile(n->boundto);
} }
} }
if(s){ // must be on new plane, with sprixels to donate if(s){ // must be on new plane, with sprixels to donate