From: Magnus L. H. <ma...@he...> - 2006-04-18 19:48:20
|
On Apr 18, 2006, at 20:21, Marcelo Matus wrote: > Probably you can use the DISOWN typemap for the 'add' method, check > the > docs and see if that fix your problems. Thanks for the tip, but I'm not sure if I understand how that should work... As far as I can see, the DISOWN typemap prevents garbage collection (in this case, in add()) -- but that's not what I want (or so I think): What I want is to make sure that when I pass a C++ object to a Python callback (in this case, add()), a reference is added, so that as long as the object is accessible to Python, its refcount never goes to zero. The problem isn't that Python does a GC on it -- the problem is that the C++ code removes a reference (which *should* be removed), and thereby it's deallocated while it's still available in Python. IMO, this sounds like a kind of behavior that should be universal... And it's certainly part of the _wrap_* functions, so I guess perhaps they aren't called? (I also guess I should construct a minimal example, so I'm sure I'm not messing this up in some other way ;) BTW: Where is the authoritative documentation for the DISOWN typemap? I can just find brief mentions of it here and there (and, e.g., an explanation in the Chicken section). > Marcelo -- Magnus Lie Hetland http://hetland.org |