[PyQt] Guaranteed avoidance of C++ destructor call

Phil Thompson phil at riverbankcomputing.com
Thu May 30 22:56:30 BST 2013


On Thu, 30 May 2013 22:49:24 +0100 (BST), John Lee <jjl at pobox.com> wrote:
> Hi
> 
> Is it possible to guarantee that a C++ destructor of a QObject wrapped
by 
> PyQt is never called?
> 
> In C++ code, I can just avoid ever deleting the QObject, by not giving
it 
> a QObject parent, so that Qt does not manage its lifetime.  In Python 
> code, it isn't obvious to me whether Python might cause the C++ d'tor to

> be called, for example during interpreter shutdown.
> 
> The particular case I'm interested in is ~QProcess, whose destructor has

> the interesting (!) behaviour of sending the KILL signal to any child 
> process that it may have started.  I want to ensure that my program 
> doesn't ever call that destructor, so that the KILL signal is guaranteed

> not to be sent (or at least, that it is only called after the child 
> process has terminated for other reasons).  Is that possible?
> 
> If I can't guarantee that from PyQt, can I write a simple sip wrapper
that 
> will achieve the same end, without copying and pasting the Qt code?

sip.setdestroyonexit() might do what you want.

Phil


More information about the PyQt mailing list