Aaron Optimizer Digulla wrote:
> Isn't it possible to install a "destroy" callback which deletes the
> python object (so when the Gtk object is deleted, the Python object
> is notified) ?
Hmm, interesting idea. It seems like it should be possible to create a
1:1 mapping using the following rules.
- When a Python object is created, it get's added to an internally
maintained dictionary that maps the Gtk object to it's Python object.
This increments the reference count of the Python object.
- When a python object needs to be returned to the user, it is fetched
from the dictionary, rather than returning a newly created object.
- When a Gtk object is destroyed, the corresponding Python object is
deleted from the object dictionary, thus decrementing the reference
count, possibly deleting the python object.
My initial thought is that this would not be terribly difficult to
implement, although I have probably missed something. James?
> Then it should be possible to make the Python objects the "base" and
> store the Gtk object in a field in the Python object and use Python
> ways to do things.
This is presently how things are done. The problem comes when you
interface to a Gtk function that returns a Gtk object, you have to find
the corresponding Python object to return to the python code. In
theory, it sounds simple. In practice, it's very easy to cause memory
leaks or segfaults. Neither occurs if you dynamically create the python
object to wrap the returned gtk object.
--
Richard Fish Enhanced Software Technologies, Inc.
Software Developer 4014 E Broadway Rd Suite 405
[EMAIL PROTECTED] Phoenix, AZ 85040
(602) 470-1115 http://www.estinc.com
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]