[PyKDE] Double free() problem in PyQt 3.15.1??

Simon Edwards simon at simonzone.com
Sat Apr 22 16:04:15 BST 2006


I've spent some more time playing with this problem some more. (See 
attachment). I've added some dumpObjectTree() calls and debug for the __del__ 
methods for the two dialogs. To me it clears looks like SIP and Python 
disagree about who is responsible for destroying the popup dialog. The 
__del__ method for the popup is called two times.

I'm confused as to what the newer exec_loop() code in QDialog was meant to do. 

%If (Qt_3_0_0 -)
	int exec() /PyName=exec_loop, ReleaseGIL,
		// Transfer ownership back to Python (a modal dialog will
		// probably have the main window as it's parent).  This means
		// the Qt dialog will be deleted when the Python wrapper is
		// garbage collected.  Although this is a little inconsistent,
		// it saves having to code it explicitly to avoid the memory
		// leak.

		sipRes = sipCpp->QDialog::exec();

It looks like it is meant to take ownership away from the parent dialog and 
let Python handle destruction of the popup. But the dumpObjectTree() lines in 
my test code say that the parent dialog always keeps the popup on it's list 
of children objects.

When the parent dialog is destroyed so are the children objects. This is a 
problem if Python thinks that it should destroy the popup too.

I can't explain why Phil's Qt only examples does not fail like the KDE 
version. :-/

It is possible to work around this problem by explicitly calling 
QDialog.removeChild() to remove the popup from the parent dialog's list of 


On Sunday 12 March 2006 18:48, Jim Bublitz wrote:
> On Sunday 12 March 2006 07:04, Phil Thompson wrote:
> > On Sunday 12 March 2006 10:04 am, Simon Edwards wrote:
> > > On Saturday 11 March 2006 20:26, Phil Thompson wrote:
> > > > On Saturday 11 March 2006 7:13 pm, Simon Edwards wrote:
> > > > > Anyway, I think I've come across a double free memory bug in PyQt
> > > > > 3.15.1. Qt complains about a "Double QObject deletion detected.", 
> > > > > valgrind points to a problem in sipKDialogBase::~sipKDialogBase().
> > > > > (Reading memory which is already free'd, and invalid free(), delete
> > > > > etc). This problem
> > >
> > > only
> > >
> > > > > appears when my app opens a dialog.

Simon Edwards             | KDE-NL, Guidance tools, Guarddog Firewall
simon at simonzone.com       | http://www.simonzone.com/software/
Nijmegen, The Netherlands | "ZooTV? You made the right choice."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qdialogdoublefree2.py
Type: application/x-python
Size: 2091 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20060422/f20d77ba/qdialogdoublefree2.bin

More information about the PyQt mailing list