[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: delwin() and deleting windows with subwindows
From: |
G. Branden Robinson |
Subject: |
Re: delwin() and deleting windows with subwindows |
Date: |
Thu, 11 Aug 2022 16:53:34 -0500 |
At 2022-08-11T12:35:49-0400, Bill Gray wrote:
> On 8/10/22 20:08, Thomas Dickey wrote:
> > 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.
>
> Well, yes... nicer, and apparently we _should_ recursively delete
> to follow the XSI Curses standard ("It [delwin] must delete
> subwindows before deleting their parent.")
>
> The only downside I see to recursive deletion would be if you did
> the following :
>
> WINDOW *win = newwin( ...);
> WINDOW *sub = subwin( win, ...);
>
> delwin( win);
> access something in sub;
>
> At present, the delwin() call would fail in ncurses and SVr4. In
> PDCurses and Solaris X/Open curses, win would be deleted and sub
> wouldn't. In either case, attempts to access something in sub
> will still work.
>
> Delete subwindows recursively, and that access attempts to read
> freed memory. One shouldn't be doing such things; once a parent
> window is deleted, you shouldn't try to do anything with the
> subwindow. But I'll bet you that some code does so, and recursive
> deletion would break that code.
Why not implement recursive deletion for now, and see if anything
squawks? Any application that chases pointers into freed memory is
surely busted at a fundamental level, quite apart from violating the
documented assumptions of the XSI Curses spec.
Regards,
Branden
signature.asc
Description: PGP signature