bug-guile-ncurses
[Top][All Lists]
Advanced

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

Re: [Bug-guile-ncurses] effects in gc handlers


From: Mike Gran
Subject: Re: [Bug-guile-ncurses] effects in gc handlers
Date: Mon, 2 May 2016 15:24:49 +0000 (UTC)

> For the record, the user to whom rain1 is refering is me.


[...]

> 
> (define stdscr (initscr))
> 
> ;; Generate a window with a box around it and return the inner box
> (define (new-boxed-win h w sy sx)
>   (let* ((win  (newwin h w sy sx))
>      (inner  (derwin win (- h 2) (- w 4) 1 2))
>      (panel-desc (new-panel win))
>      (panel-desc2 (new-panel inner)))
>     (box win (acs-vline) (acs-hline))
>     ;; If the GC runs here, it will reap win, panel-desc and panal-desc2
>     inner))


[...]

> 
> Depending on when/if the garbage collector runs, this sometimes works, but 
> sometimes displays nothing, because all panels, and outer windows have get 
> garbage collected before they should be.

Ah, right.  In ncurses, 'win' and 'derwin' share the same memory space.
The C procedures subwin() and derwin() don't create independent objects.
Rather, they extend the original window object.  So your 'win' and
'derwin' need to have the same lifetimes.  That's why the current code
deletes the derived windows upon garbage collection.

But I agree it is not the best solution.  Really, the parent window
should exist as long as any subwindows or derived windows exist.

I hadn't considered this case.


reply via email to

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