weakened userdata

When making a signal callback in a child widget to act on some parent,
with the parent as the userdata in the signal, is there a usual way to
weaken or do something to that userdata to avoid creating a circular

Including possibly a child component which is a popup menu and so not
directly in the widget heirarchy.  And/or likewise for timer or idle
callbacks acting on a widget.

I've fiddled around with a weakened "reference to a reference" and a
destroy signal handler on the target to disconnect the
signal/timer/idle.  Or a callback wrapper noticing the weak ref has gone
"undef".  Both of which work, but perhaps there's an easier way.

I guess in C you don't (or don't necessarily) increment the reference
count when something is in a userdata, but just let a destroy method get
rid of the handler before the pointer becomes invalid.  (Or in lisp it's
just another circular reference handled by the GC with no special help.)

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