[Gambas-devel] GB.Signal.Register() keeps program running?

Benoît Minisini gambas at ...1...
Sun Apr 6 13:06:42 CEST 2014


Le 06/04/2014 11:21, Tobias Boege a écrit :
> On Sat, 05 Apr 2014, Beno?t Minisini wrote:
>> Le 05/02/2014 12:58, Tobias Boege a ?crit :
>>>>
>>>> Yes, you must use GB.Signal.Unregister() to remove the signal handler.
>>>>
>>>
>>> Hmm, but when? How about this: I always register the signal handler and use
>>> GB_HOOK_WATCH to detect when nothing is watched anymore. Then, I can remove
>>> the signal handler and the program will terminate.
>>>
>>> The only case where this doesn't work, is when nothing is watched at all
>>> during the process' lifetime...
>>>
>>> Regards,
>>> Tobi
>>>
>>
>> Hi Tobias,
>>
>> I suggest that you have a counter that counts the number of opened windows
>> (do you have just one with gb.ncurses?).
>>
>> When you create/open a window, you increment the counter, and call
>> GB.Signal.Register() for the first window.
>>
>> Then you add a Window.Close() method. If the user calls it, the window is
>> closed (whatever that means), and the counter is decremented. If the counter
>> reaches zero, then you call GB.Signal.Unregister().
>>
>> It will be up to the user to call the Close() method to end the program.
>>
>> What do you think?
>>
>
> There are potentially multiple windows in gb.ncurses and a Close() method
> makes perfect sense, even in the terms of ncurses (delwin()). But if you
> close a window then, you can't open it anymore - it is destroyed.
>
> Would that behaviour be compatible with that of other Window classes
> (like in gb.qt4)? If not, I could trick a bit so that the window seems gone
> and the counter is decremented but the window is always ready to be
> repainted.

Do your best. If "closing" <> "destroy" is useful with gb.ncurses, 
implement it. Otherwise don't.

>
>> By the way, why both ncurses example have a red background? It is normal?
>>
>
> Ui! Normally (read: on my system) they're black. But neither Pong nor
> Invaders modify the background. Has your terminal a red background by
> default?
>
> Regards,
> Tobi
>

No, my background is black. This is why I found that strange. I use KDE 
and so my terminal emulator is Konsole.

-- 
Benoît Minisini




More information about the Devel mailing list