*** GMX Spamverdacht *** Re: [Eric] Bugs in latest eric4 snapshot

Andreas Pakulat apaku at gmx.de
Wed Apr 4 22:25:18 BST 2007


On 04.04.07 22:20:17, Jürgen Urner wrote:
> Andreas Pakulat schrieb:
> >On 04.04.07 02:14:05, Andreas Pakulat wrote:
> >>just updated to python2.5 and latest snapshots of pyqt4/sip/eric4
> >>(20070402) and trying to start it I get:
> >>
> >>An unhandled exception occurred. Please report the problem using the error 
> >>reporting dialog or via email to <eric4-bugs at die-offenbachs.de>. A log has 
> >>been written to "/home/andreas/.eric4/eric4_error.log".
> >>    
> >
> >This seems to be a serious bug in BrowserModel.py, it created indices
> >using createIndex( row, column, item ) and later on it uses indices that
> >are given to it (for example in the item() function) to retrieve the
> >item from a dict. This can't work, using createIndex() will set the
> >internalPointer() of that index, but internalId() will return some
> >"arbitrary" value (i.e. -1.....). So BrowserModel.py needs to be fixed
> >to be consistent, either always use createIndex(row,col,id(item)) or
> >always use internalPointer() instead of internalId(). 
> >However a simple replace in all createIndex() calls still doesn't
> >completely fix the model, it seems that something tries to call item()
> >with non-source-model indices. I added a print for the pointer and id to
> >the item() function adn this is the result:
> >
> ><refcnt -1257449590 at 0xb50cd770> -1257449616
> >An unhandled exception occurred. Please report the problem using the error 
> >reporting dialog or via email to <eric4-bugs at die-offenbachs.de>. A log has 
> >been written to "/home/andreas/.eric4/eric4_error.log".
> 
> I fell for this, too ...tripple reading the docs for QModelIndex helps.
> It says: indices returned by CreateIndex() may (that is will !!) become
> invalid over time.
> 
> they become invalid for shure when as an item is inserted ahead of
> an index or an item is removed ahead of an index. From then on you
> are in the hands of GC.

Of course the internalPointer becomes invalid when there's no reference
to the object anymore, however thats why eric uses a dict of the
objects. So unless its model doesn't call beginRemoveRows() before
deleting some object from the dict, there shouldn't be any problem.

Anyway, I'm going to put the Qt ModelTest class that I ported from C++
into eric and see what it can find on the BrowserModel.

> QPersistantModelIndex seems to be no help either (when reading the docs
> carefully). Maybe I am missing something here, but the only solution seems to
> be to implement a model wich does not rely on model indices being persistant
> at all.

Model indices are not persistent across application runs, but the Qt
views do cache model indices that they retrieve from the model. As I
said above, if you use internalPointer in python you need to make sure
to keep a reference to the object yourself, i.e. in a list or dict.
Thats why I tend to use internalId and keep a dict of id->object in the
model.

Andreas

-- 
Don't read any sky-writing for the next two weeks.


More information about the Eric mailing list