Hello, 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,
PreHook=__pyQtPreEventLoopHook__,
PostHook=__pyQtPostEventLoopHook__/;
%MethodCode
// 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.
sipTransferBack(sipSelf);
Py_BEGIN_ALLOW_THREADS
sipRes = sipCpp->QDialog::exec();
Py_END_ALLOW_THREADS
%End
%End
-----------------------------------
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
children.
cheers,
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.",
and
> > > > > 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
[EMAIL PROTECTED] | http://www.simonzone.com/software/
Nijmegen, The Netherlands | "ZooTV? You made the right choice."
qdialogdoublefree2.py
Description: application/python
_______________________________________________ PyKDE mailing list [email protected] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
