Sorry, I am returning to this with some delay.

> It may happen, that Qt deletes the underlying C++ object, but Python
> doesn't know this, and still keeps the wrapper object alive, because
> there are still valid references to it.  As long as there is any
> reference, this object is still alive, and its __del__ method will
> consequently not be invoked.

OK. This was exactly my mistake: I believed that the wrapper and Qt itself were 
so closely coupled that Qt's deletions would affect the corresponding Python 
objects.

In fact, when things did not work I intuitively put an explicit del into the 
close event of the main window. This resolved the problem but I never 
understood why. Now I do - thanks!

> 
> Pythons memory management should be considered non-deterministic, just
> like with other managed platforms.  __del__ is therefore not the
> Python equivalent to a C++ destructor, and it should not be used this
> way.  I do know your indent in using __del__ in this specific
> situation, but avoid it, if at all possible.  Move cleanup work to
> other methods (e.g. a event callback or a slot connected to the
> "deleted" signal), which are guaranteed to be invoked in a certain
> situation.

The class in question is Python-wrapped C-Code, which spawns a process. That 
process is a Lisp System, which occupies a considerable amount of memory. I 
would thus be very happy about any advice how to arrange my code in such a way 
that the destructor - or more generally the corresponding code for the deletion 
of the questionable process - is called on termination of the Python program 
under any circumstances - including abnormal termination due to bugs, kill -9 
from outside, or whatever. Is this possible?

Thomas

-- 
Dr. habil. Thomas Sturm
Departamento de Matematicas, Estadistica y Computacion
Universidad de Cantabria, Santander, Spain
Avda. Los Castros s/n, Room 1072, +34 693 251058
http://personales.unican.es/sturmt/

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
PySide mailing list
[email protected]
http://lists.openbossa.org/listinfo/pyside

Reply via email to