Re: [C++-sig] Custom memory management

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Re: [C++-sig] Custom memory management

Eric Jardim
Let's do some "flashback" here:

2005/7/29, Niall Douglas <[hidden email]>:
Custodian and ward won't help you here. This is happening because
python likes to manage the lifetime of its objects and doesn't know
when Qt deletes them from underneath it.

Hmm, so that was the problem. Python didn't notice when some objects where destroyed in C++.

> Besides, I suspect that I reference the same C++ object more than one
> time which might be a problem.

Shouldn't be. BPL refcounts.

This was other problem. But now is solved.

Make your wrappers hold an auto_ptr to your Qt objects. This works as
you'd expect it. Upcall when Qt deletes an object to the python layer
so it zeros the auto_ptr so python won't delete anything later. If
you want to see it in action, see how TnFOX does it at (get the most recent snapshot).

So, do you think auto_ptr will do the trick. I'll try it.

What do you mean by "upcall"? I really did not understood this sentense (sorry).

Can you show me one of your classes in TnFOX that acts like QObject class in Qt (parent->child)?


[Eric Jardim]

C++-sig mailing list
[hidden email]