Simon Edwards <[EMAIL PROTECTED]> 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.
>
> This problem does not occur with PyQt 3.14.1. Comparing the two PyQt
> releases I see this added to the 3.15.1 qdialog.sip:
>
> -----------------------------
> %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
> -----------------------------
>
> This does look like it could be the problem. Phil?


Do you have a sample source code which shows the crash? That call to
sipTransferBack is actually very important to properly avoid memory leak, so
I'm curious how it could trigger a double deletion. Notice that there are
some way to make PyQt crash with double deletion, such as:

=========================
from qt import *

app = QApplication([])
w1 = QWidget(None)
w2 = QWidget(w1)
w2.xxxx = w1
w2.deleteLater()

del w1
del w2

app.processEvents()
=========================

but they have nothing to do with the code you quoted.
-- 
Giovanni Bajo

_______________________________________________
PyKDE mailing list    PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

Reply via email to