mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-08 01:10:23 +00:00
[multiselector] refuse a bound plane #2347
This commit is contained in:
parent
717b4a40c1
commit
ce2a6dc686
@ -882,6 +882,10 @@ ncmultiselector_dim_yx(const ncmultiselector* n, unsigned* ncdimy, unsigned* ncd
|
||||
}
|
||||
|
||||
ncmultiselector* ncmultiselector_create(ncplane* n, const ncmultiselector_options* opts){
|
||||
if(n == notcurses_stdplane(ncplane_notcurses(n))){
|
||||
logerror("won't use the standard plane\n"); // would fail later on resize
|
||||
return NULL;
|
||||
}
|
||||
ncmultiselector_options zeroed = {};
|
||||
if(!opts){
|
||||
opts = &zeroed;
|
||||
@ -959,8 +963,10 @@ ncmultiselector* ncmultiselector_create(ncplane* n, const ncmultiselector_option
|
||||
if(ncplane_resize_simple(ns->ncp, dimy, dimx)){
|
||||
goto freeitems;
|
||||
}
|
||||
if(ncplane_set_widget(ns->ncp, ns, (void(*)(void*))ncmultiselector_destroy)){
|
||||
goto freeitems;
|
||||
}
|
||||
ncmultiselector_draw(ns); // deal with error here?
|
||||
ncplane_set_widget(ns->ncp, ns, (void(*)(void*))ncmultiselector_destroy);
|
||||
return ns;
|
||||
|
||||
freeitems:
|
||||
|
@ -11,6 +11,13 @@ TEST_CASE("Selectors") {
|
||||
REQUIRE(n_);
|
||||
REQUIRE(0 == ncplane_cursor_move_yx(n_, 0, 0));
|
||||
|
||||
// selector can't be bound to the standard plane
|
||||
SUBCASE("RefuseStandardPlane") {
|
||||
ncselector_options s{};
|
||||
struct ncselector* ns = ncselector_create(n_, &s);
|
||||
REQUIRE(nullptr == ns);
|
||||
}
|
||||
|
||||
// create a selector, but don't explicitly destroy it, thus testing the
|
||||
// context shutdown cleanup path
|
||||
SUBCASE("ImplicitDestroy") {
|
||||
|
Loading…
Reference in New Issue
Block a user