weakened userdata
- From: Kevin Ryde <user42 zip com au>
- To: gtk-perl-list gnome org
- Subject: weakened userdata
- Date: Sun, 30 Dec 2007 11:34:15 +1100
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
reference?
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]