bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: delwin() and deleting windows with subwindows


From: Thomas Dickey
Subject: Re: delwin() and deleting windows with subwindows
Date: Wed, 10 Aug 2022 20:08:05 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Tue, Aug 09, 2022 at 09:51:52PM -0400, Bill Gray wrote:
>    The man page for this function [1] says
> 
>     "...Calling delwin deletes the named window, freeing all memory
> associated  with  it... Sub-windows must be deleted before the main window
> can be deleted."
> 
>    And under "return value",  it says that delwin "returns an error value...
> if the window is the parent of another window."
> 
>    I wrote a small bit of test code [2] that seems to confirm all this,  at
> least with ncurses-6.2.

yes... something got my attention on this recently, but I don't recall what.

The code is not recent :-)
 
>    The problem is that further down the man page,  under "portability",  it
> says :
> 
>    "Since release 4.0 (1996), ncurses maintains a list of windows for each
> screen,  and is able to recursively delete subwindows when asked to delete
> their parent.  NetBSD copied this feature of ncurses in 2003."
> 
>    I've implemented the recursive deletion for PDCursesMod.  But now I'm
> wondering if I should have just returned an error code if delwin() is called
> for a parent window.  Easy enough either way,  but I don't know which way to
> go.

it depends: in the SVr4 code, child-windows have a link to their parent,
using that to maintain a reference count -- and tell it if there are no
remaining children, and return an error if any remain.  But that's not
enough to just delete all of the children and the parent window, which
would make it nice(r) for applications.

-- 
Thomas E. Dickey <dickey@invisible-island.net>
https://invisible-island.net
ftp://ftp.invisible-island.net

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]