[PyQt] Segfault when activating items in a view, more info
Andreas Pakulat
apaku at gmx.de
Mon Aug 9 11:20:36 BST 2010
On 09.08.10 12:06:57, Hans-Peter Jansen wrote:
> 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
If you use this model on a treeview you'll probably end up in an infinite
tree size. The reason is that you're returning a child-count of 2 for each
and every index (and the treeview is going to ask for the row-count of each
toplevel entry). Try to add a check for index.isValid() and only return 2
if its not a valid index.
Andreas
--
Cheer Up! Things are getting worse at a slower rate.
More information about the PyQt
mailing list