Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyQT open a web page with JS alert pop up will get SegFault. How to fix that?

Tags:

I am learning PyQT programing, and when I try a simple test, I get Segmentation fault, here is my code pop.py:

#! /usr/bin/python  import sys from PyQt4.QtGui import QApplication from PyQt4.QtCore import QUrl from PyQt4.QtWebKit import QWebView  app = QApplication(sys.argv) v = QWebView() v.load(QUrl("http://127.0.0.1/j.html")) v.show() app.exec_() 

I started an Apache server at 127.0.0.1 for testing. And here is j.html:

<html><script>alert("I am here");</script> <body>Hello World</body> </html> 

I start the pop.py, open a window, javascript popup alert dialog, I click the OK, then pop.py will quite and get "Segmentation fault"

I tried PySide, get same result. If not JS alert in html, will be OK. Is this a bug of QT or I missed something?

I worked on Debian with python 2.6.6, python-qt4 4.8.3, libqtwebkit4 2.1.0

I also tried Fedora 15 with PyQt4-4.8.3, python 2.7.1, same issue

Any suggestion, clue for searching will be helpful. Thanks

like image 370
PasteBT Avatar asked Dec 01 '11 22:12

PasteBT


1 Answers

This works with the test case given above for

Qt:     4.7.2 PyQt:   4.8.3 or PySide 1.0.1 Python: 2.7.1 

As noted above in the comments, http://developer.qt.nokia.com/forums/viewthread/4760 explains the bug and it is reported as fixed from https://bugs.webkit.org/show_bug.cgi?id=57414 and was probably included in Qt 4.7.2.

like image 163
gfortune Avatar answered Dec 12 '22 14:12

gfortune