[PyQt] Segfault when activating items in a view, more info

Hans-Peter Jansen hpj at urpla.net
Mon Aug 9 11:06:57 BST 2010


Hi Peter,

while not of big help, here are a few more details and the backtrace.

Qt 4.6.3, sip 4.10.5, PyQt4 4.7.4.

On Monday 09 August 2010, 09:42:05 peter at lohmanders.se wrote:
> Yes, the connect signal had the wrong signature, but that doesn't matter.
> I do not get a warning when trying to connect invalid signals, but
> even if I have no activated-signal connected, the darn thing still
> segfaults when I double click any cell.

Well, even with a correct signal, this crashes (after executing the signal
handler):

import sys
from PyQt4 import QtGui, QtCore

class TestModel(QtCore.QAbstractTableModel):

    def headerData(self, section, orientation, role =
                   QtCore.Qt.DisplayRole):
        return QtCore.QVariant("a")

    def data(self, index, role = QtCore.Qt.DisplayRole):
        if (role == QtCore.Qt.DisplayRole
            and index.isValid()
            and 0 <= index.row() < 2
            and 0 <= index.column() < 2):
            return QtCore.QVariant("t")
        return QtCore.QVariant()

    def columnCount(self, index):
        return 2

    def rowCount(self, index):
        return 2


def onActivated():
    print "activated"


if __name__ == "__main__":
    app = QtGui.QApplication([])
    win = QtGui.QMainWindow()
    model = TestModel()
    view = QtGui.QTreeView()
    view.setModel(model)
    view.setRootIsDecorated(False)
    view.activated.connect(onActivated)
    win.setCentralWidget(view)
    win.show()
    app.exec_()


Starting program: /usr/bin/python model.py
[Thread debugging using libthread_db enabled]
activated

Program received signal SIGSEGV, Segmentation fault.
0xb7ef3e54 in PyEval_EvalFrameEx (f=0x83aa6bc, throwflag=0) at Python/ceval.c:725
725             if (tstate->use_tracing) {
(gdb) bt
#0  0xb7ef3e54 in PyEval_EvalFrameEx (f=0x83aa6bc, throwflag=0) at Python/ceval.c:725
#1  0xb7efabcb in PyEval_EvalCodeEx (co=0xb7c230f8, globals=0xb7c7802c, locals=0x0, args=0xb7c42c38, argcount=2, 
    kws=0x0, kwcount=0, defs=0x81f0558, defcount=1, closure=0x0) at Python/ceval.c:2942
#2  0xb7e8fa29 in function_call (func=0x81a633c, arg=0xb7c42c2c, kw=0x0) at Objects/funcobject.c:524
#3  0xb7e6ac1c in PyObject_Call (func=0x81a633c, arg=0xb7c42c2c, kw=0x0) at Objects/abstract.c:2487
#4  0xb7e789fe in instancemethod_call (func=0x81a633c, arg=0xb7c42c2c, kw=0x0) at Objects/classobject.c:2579
#5  0xb7e6ac1c in PyObject_Call (func=0xb7c28734, arg=0x81f076c, kw=0x0) at Objects/abstract.c:2487
#6  0xb7ef377f in PyEval_CallObjectWithKeywords (func=0xb7c28734, arg=0x81f076c, kw=0x0) at Python/ceval.c:3548
#7  0xb7533bf3 in sip_api_call_method (isErr=0x0, method=0xb7c28734, fmt=0xb6268724 "N") at siplib.c:1709
#8  0xb613fdfe in ?? () from /usr/lib/python2.6/site-packages/PyQt4/QtCore.so
#9  0xb623030f in ?? () from /usr/lib/python2.6/site-packages/PyQt4/QtCore.so
#10 0xb6955284 in QAbstractTableModel::hasChildren (this=0x826e620, parent=@0xbf8007c4)
    at kernel/qabstractitemmodel.cpp:3053
#11 0xb71a4930 in QTreeViewPrivate::layout (this=0x82a0b48, i=29080) at itemviews/qtreeview.cpp:3138
#12 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29079) at itemviews/qtreeview.cpp:3182
#13 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29078) at itemviews/qtreeview.cpp:3182
#14 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29077) at itemviews/qtreeview.cpp:3182
#15 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29076) at itemviews/qtreeview.cpp:3182
#16 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29075) at itemviews/qtreeview.cpp:3182
#17 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29074) at itemviews/qtreeview.cpp:3182
#18 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29073) at itemviews/qtreeview.cpp:3182
#19 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29072) at itemviews/qtreeview.cpp:3182
#20 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29071) at itemviews/qtreeview.cpp:3182
#21 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29070) at itemviews/qtreeview.cpp:3182
#22 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29069) at itemviews/qtreeview.cpp:3182
#23 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29068) at itemviews/qtreeview.cpp:3182
#24 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29067) at itemviews/qtreeview.cpp:3182
#25 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29066) at itemviews/qtreeview.cpp:3182
#26 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29065) at itemviews/qtreeview.cpp:3182
#27 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29064) at itemviews/qtreeview.cpp:3182
#28 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29063) at itemviews/qtreeview.cpp:3182
#29 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29062) at itemviews/qtreeview.cpp:3182
#30 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29061) at itemviews/qtreeview.cpp:3182
#31 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29060) at itemviews/qtreeview.cpp:3182
#32 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29059) at itemviews/qtreeview.cpp:3182
#33 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29058) at itemviews/qtreeview.cpp:3182
#34 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29057) at itemviews/qtreeview.cpp:3182
#35 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29056) at itemviews/qtreeview.cpp:3182
#36 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29055) at itemviews/qtreeview.cpp:3182
#37 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29054) at itemviews/qtreeview.cpp:3182
#38 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29053) at itemviews/qtreeview.cpp:3182
#39 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29052) at itemviews/qtreeview.cpp:3182
#40 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29051) at itemviews/qtreeview.cpp:3182
#41 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29050) at itemviews/qtreeview.cpp:3182
#42 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=29049) at itemviews/qtreeview.cpp:3182
[...]
#29068 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=23) at itemviews/qtreeview.cpp:3182
#29069 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=22) at itemviews/qtreeview.cpp:3182
#29070 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=21) at itemviews/qtreeview.cpp:3182
#29071 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=20) at itemviews/qtreeview.cpp:3182
#29072 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=19) at itemviews/qtreeview.cpp:3182
#29073 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=18) at itemviews/qtreeview.cpp:3182
#29074 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=17) at itemviews/qtreeview.cpp:3182
#29075 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=16) at itemviews/qtreeview.cpp:3182
#29076 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=15) at itemviews/qtreeview.cpp:3182
#29077 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=14) at itemviews/qtreeview.cpp:3182
#29078 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=13) at itemviews/qtreeview.cpp:3182
#29079 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=12) at itemviews/qtreeview.cpp:3182
#29080 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=11) at itemviews/qtreeview.cpp:3182
#29081 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=10) at itemviews/qtreeview.cpp:3182
#29082 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=9) at itemviews/qtreeview.cpp:3182
#29083 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=8) at itemviews/qtreeview.cpp:3182
#29084 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=7) at itemviews/qtreeview.cpp:3182
#29085 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=6) at itemviews/qtreeview.cpp:3182
#29086 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=5) at itemviews/qtreeview.cpp:3182
#29087 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=4) at itemviews/qtreeview.cpp:3182
#29088 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=3) at itemviews/qtreeview.cpp:3182
#29089 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=2) at itemviews/qtreeview.cpp:3182
#29090 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=1) at itemviews/qtreeview.cpp:3182
#29091 0xb71a51f9 in QTreeViewPrivate::layout (this=0x82a0b48, i=0) at itemviews/qtreeview.cpp:3182
#29092 0xb71a6ff8 in QTreeViewPrivate::expand (this=0x82a0b48, item=0, emitSignal=true) at itemviews/qtreeview.cpp:2938
#29093 0xb71a8302 in QTreeView::mouseDoubleClickEvent (this=0x82a3fd0, event=0xbfffdde8)
    at itemviews/qtreeview.cpp:1880
#29094 0xb76afb1f in ?? () from /usr/lib/python2.6/site-packages/PyQt4/QtGui.so
#29095 0xb6c18687 in QWidget::event (this=0x82a3fd0, event=0xbfffdde8) at kernel/qwidget.cpp:8048
#29096 0xb7012713 in QFrame::event (this=0x82a3fd0, e=0xbfffdde8) at widgets/qframe.cpp:557

The delay is due to the runaway layout walk. I've tried to limit this 
by providing valid boundary checks in data(), but the result is still 
crashing and feels like a genuine PyQt issue.

Phil's call, I guess.

Cheers,
Pete


More information about the PyQt mailing list