You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
notcurses/src/libcpp
Marek Habersack a29bfe9c42 [C++] Deal with widgets grabbing full ownership of Panel
Fixes: https://github.com/dankamongmen/notcurses/issues/1009

Whenever a widget is created with its `*_create` function it currently
claims full ownership of the passed panel, including its destruction.
However, the C++ wrapper around the panel is not aware of this and will
attempt to destroy the native panel in the destructor, leading to
segfaults.

Fix this by introduction of a `Widget` class which contains the logic to
properly modify the `Panel` instance to not double-destroy the native
panel.  The solution is a bit fragile since the `Panel` instance is left
intact (we can't free it for the user) in a state that's safe for the
C++ wrapper, but calling any C function via the wrapper **will** pass a
`NULL` pointer in the panel argument - therefore the C functions MUST be
proofed against this.  The proofing belongs in the C backend code since
this protects also C and other language binding users from such abuse.

The Widget class will first verify that the passed `Plane` instance
hasn't already been "disowned" and will throw an exception to the effect
if it was.  Next, it will proceed to take over ownership of the native
panel instance and mark the passed `Panel` as "invalid" (i.e. not owning
any native panel instance anymore)

The above changes require modification of `Panel` instances and so all
the widget constructors taking `const*` or `const&` have been removed
from widget classes.
4 years ago
..
FDPlane.cc subproc, fdplane, plot, selector, mselector: flag words #590 4 years ago
Menu.cc ncmenu: move to flag field #590 4 years ago
MultiSelector.cc remove bgchannels field from selector_options #627 4 years ago
NotCurses.cc [C++] API sync 4 years ago
Plane.cc [C++] Deal with widgets grabbing full ownership of Panel 4 years ago
Plot.cc ncplot: C++ headers need match declaration order #627 4 years ago
Reel.cc [C++] API sync 4 years ago
Root.cc [C++] Allow multiple instances of `NotCurses` 4 years ago
Selector.cc remove bgchannels field from selector_options #627 4 years ago
Subproc.cc subproc, fdplane, plot, selector, mselector: flag words #590 4 years ago
Tablet.cc nctablet_ncplane() -> nctablet_plane() 4 years ago
Utilities.cc [C++] Allow multiple instances of `NotCurses` 4 years ago