From 322ee8309d645f29986f89b4f2b221c1b435b791 Mon Sep 17 00:00:00 2001 From: nick black Date: Tue, 27 Apr 2021 21:26:37 -0400 Subject: [PATCH] ncplayer: use a different plane for each file --- src/player/play.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/player/play.cpp b/src/player/play.cpp index 1e5837fdb..1d8bc4025 100644 --- a/src/player/play.cpp +++ b/src/player/play.cpp @@ -375,14 +375,14 @@ int rendered_mode_player_inner(NotCurses& nc, int argc, char** argv, nopts.margin_b = 1; nopts.resizecb = ncplane_resize_marginalized; nopts.flags = NCPLANE_OPTION_MARGINALIZED; - auto n = ncplane_create(*stdn, &nopts); - if(!n){ - return -1; - } - ncplane_move_bottom(n); for(auto i = 0 ; i < argc ; ++i){ std::unique_ptr ncv; ncv = std::make_unique(argv[i]); + auto n = ncplane_create(*stdn, &nopts); + if(!n){ + return -1; + } + ncplane_move_bottom(n); struct ncvisual_options vopts{}; int r; vopts.flags |= NCVISUAL_OPTION_HORALIGNED | NCVISUAL_OPTION_VERALIGNED; @@ -415,6 +415,7 @@ int rendered_mode_player_inner(NotCurses& nc, int argc, char** argv, if(displaytime < 0){ stdn->printf(0, NCAlign::Center, "press a key to advance"); if(!nc.render()){ + ncplane_destroy(n); return -1; } char32_t ie = nc.getc(true); @@ -433,6 +434,7 @@ int rendered_mode_player_inner(NotCurses& nc, int argc, char** argv, }else if(ie == NCKey::Resize){ --i; // rerun with the new size if(!nc.refresh(&dimy, &dimx)){ + ncplane_destroy(n); return -1; } } @@ -450,10 +452,12 @@ int rendered_mode_player_inner(NotCurses& nc, int argc, char** argv, }while(loop && r == 0); if(r < 0){ // positive is intentional abort std::cerr << "Error while playing " << argv[i] << std::endl; + ncplane_destroy(n); return -1; } + free(ncplane_userptr(n)); + ncplane_destroy(n); } - free(ncplane_userptr(n)); return 0; }