[PyQt] Possible bug: Instantiating QWebPage results in segfault

Phil Thompson phil at riverbankcomputing.com
Sat Mar 2 08:54:46 GMT 2013


On Fri, 01 Mar 2013 23:44:51 -0700, Ken Kinder <kkinder at gmail.com> wrote:
> Howdy. I may have found a bug, but because simple script will cause a
> segfault:
> 
>     #!/usr/bin/env python
> 
>     import sys
>     from PyQt4 import Qt
>     from PyQt4.QtWebKit import QWebPage
> 
>     a = Qt.QApplication(sys.argv)
>     p = QWebPage()
>     hello = Qt.QLabel("Hello, World")
>     hello.show()
>     a.exec_()
> 
> This is with PyQt 4.9.3-4, Qt 4.8.0, Python2.7 on an Ubuntu 12.10 box.
> 
> You can add deleteLater() to avoid the segfault, but it shouldn't
> segfault just because you used the Python garbage collector.
> 
> Thoughts?

Qt has its on internal, undocumented (and probably version dependent)
requirements about the order in which C++ dtors are called. The Python
garbage collector does not destroy objects in any predictable order. From
time to time the two clash.

Apart from deleteLater() you could explicitly del the QWebPage instance,
or give it a parent, or call sip.setdestroyonexit(False) somewhere in your
code. The latter will probably be the default in PyQt5.

Phil


More information about the PyQt mailing list