[PyQt] Problem with implementation of dummy (no-op) proxy model

Hans Meine meine at informatik.uni-hamburg.de
Wed Oct 27 19:34:18 BST 2010


Hi,

I am having lots of crashes with my implementation of a dummy proxy model.  
Could someone please look at this and tell me at which point I am being stupid 
(and blind) or whether this is a problem with [Py]Qt?

I have attached a stripped down test case that crashes for me (i.e. segfault/ 
bus error/glibc double free).

For now, I just want to have a model that wraps another model and forwards all 
calls (for future expansion of course).  Could there be a simpler model?

There are two obvious ways to implement such a proxy model, one is to let the 
internalPointer() point to the corresponding model index of the proxied Views 
model, and one is to let the internalPointer() point to the corresponding 
*parent* model.

The former leads to slightly simpler code in the pure dummy model case, but 
leads to a duplication of the row/column information.  Although this is quite 
ugly, I attached this (simpler) variant.

I am getting crashes when accessing internalPointer(), as I can see by single-
stepping through the code in pdb.  I also tried using QPersistentModelIndex 
for the internalPointer() (although I am just dealing with static models), but 
that did not resolve the crashes either.

In the attached test case, in which I set up a QStringListModel for testing, 
it additonally fails with "TypeError: QAbstractListModel.parent() is a private 
method".   (Maybe I am too tired now, but that looks like a bug in 
QAbstractListModel to me; parent() should not be private.)

Thanks for looking at it,
  Hans
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dummy_proxy.py
Type: text/x-python
Size: 2978 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20101027/fea42e1e/attachment.py>


More information about the PyQt mailing list