[PyQt] catch a Segmentation Fault from PyQt?

Jugdish jugdizh at gmail.com
Thu Apr 22 15:13:28 BST 2010


Is there any way to catch a segfault caused by Qt (for example, to log it to
a file, etc)? I've tried installing a handler for the SIGSEGV signal, but it
doesn't seem to work when a segfault occurs within PyQt. Example:

#####################

# install a signal handler
import signal
def handler(signum, frame):
    print "Signal handler for signal", signum
signal.signal(signal.SIGSEGV, handler)

from PyQt4.QtCore import *
from PyQt4.QtGui import *

app = QApplication([])

model = QStandardItemModel(1,1)
model.setItem(0,0,QStandardItem("foo"))

proxyModel = QSortFilterProxyModel()
proxyModel.setSourceModel(model)

# cause a Segmentation fault to happen
print "causing segfault"
index = proxyModel.index(0,0)
print index.internalPointer()

app.exec_()

########################

when I run this, the program just hangs forever, and I never see the print
statement in my handler.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100422/afa25120/attachment.html>


More information about the PyQt mailing list