ncplane_dup: don't dup sprixcells #1654

This commit is contained in:
nick black 2021-05-13 21:09:30 -04:00
parent 8bd73378cf
commit ce2f2c6509

View File

@ -555,11 +555,20 @@ ncplane* ncplane_dup(const ncplane* n, void* opaque){
.flags = 0,
};
ncplane* newn = ncplane_create(n->boundto, &nopts);
if(newn){
if(newn == NULL){
return NULL;
}
// we don't duplicate sprites...though i'm unsure why not
size_t fbsize = sizeof(*n->fb) * dimx * dimy;
if(n->sprite == NULL){
if(egcpool_dup(&newn->pool, &n->pool)){
ncplane_destroy(newn);
return NULL;
}
memmove(newn->fb, n->fb, fbsize);
}else{
memset(newn->fb, 0, fbsize);
}
if(ncplane_cursor_move_yx(newn, n->y, n->x) < 0){
ncplane_destroy(newn);
return NULL;
@ -567,11 +576,8 @@ ncplane* ncplane_dup(const ncplane* n, void* opaque){
newn->halign = n->halign;
newn->stylemask = ncplane_styles(n);
newn->channels = ncplane_channels(n);
memmove(newn->fb, n->fb, sizeof(*n->fb) * dimx * dimy);
// we dupd the egcpool, so just dup the goffset
newn->basecell = n->basecell;
}
}
return newn;
}