How to make sure GC allocated resources stay around when used in C functions?

Gary Willoughby via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 14 11:35:00 PDT 2014


On Wednesday, 14 May 2014 at 07:11:45 UTC, Kagamin wrote:
> It must be scanned, so you shouldn't specify NO_SCAN attribute, 
> it's for memory blocks, which are guaranteed to not hold 
> pointers to GC memory, like ubyte[] buffers for i/o, so managed 
> blocks can be safely collected without looking at content of 
> NO_SCAN blocks.

Ah yes. I've completed the changes and that has cured the 
problems i was experiencing and fixed a nasty bug. Thanks.

>> They are not bound automatically but may be bound later.
>
> So they will be allocated on demand - only if it's bound, Args 
> will be allocated,

Yes.

> so widget will have only one Args allocated, or as many as were 
> actually bound. Or do you want to save on one pointer per 
> widget?

By default most widget have none bound until a command or binding 
is added. Only one command can be added to widgets that support 
it (e.g. buttons) but all can have many events bound if the 
developer so wishes.

> Keyboard shortcuts are probably rare too, widgets should handle 
> most common shortcuts like text editing or copying on their own 
> without special handling by the user program, right?

They do but you are free to bind actions to more events if you 
wish.


More information about the Digitalmars-d-learn mailing list