Sorry, this went out private, not to the mailing list as intendet.
Andreas Pakulat schrieb:
> On 05.04.07 12:39:16, Jürgen Urner wrote:
>>> Andreas Pakulat schrieb:
>>>>> On 05.04.07 00:03:18, Jürgen Urner wrote:
>>>>>>>>>> Andreas Pakulat schrieb:
>>>>>>>>> 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.
>>>>>> ...
>>>> Anyway, I don't quite understand what you wanted to point at? The
>>> problematic code in eric4 does something like
>>>>>> index = sourceModel.index(row,col)
>>> item = sourceModel.item(index)
>>>>>> which is defined to be perfectly ok, i.e. the model can expect to get a
>>> proper index with a proper internalPointer or internalId, depending on
>>> which createIndex() overload it used. If an index turns out to be not
>>> invalid _and_ not have a proper id/pointer then the caller is doing
>>> something wrong. In the eric4 case I'm not sure yet, wether its the
>>> view
>>> or the filter model, because I haven't looked at the rest of the code
>>> yet...
>>>>>>>> In BrowserModel a mapping is maintaned index.internalId -->
>> BrowserItem.
>>>> Right.
>>>> In cretaeIndex() a reference to the parent item is attatched to an
>> index and later retrieved in calls to self.item_dict[index.internalId()]
>>>> And here's at least 1 error. eric calls createIndex with the actual
> item, which means the internalPointer will return this item, however
> internalId will return some totally random value, which can't be used
> for indexing into the dict.
>
Dono about the details... internalId() vs. internalPointer().
I stopped using these methods when running into these
problems. Anyway, you pass a python object. Qt should treat
is as pointer and don't care any longer, that is, wether the pointer
is valid or not at any time. Off course I may be wrrong here.
>>> The (Python) id or an item is mapped to items and, if I understand it
>> right,
>> the item is retrieved later by its (Qt | Python ?) id.
>>>> The model as it is available in the snapshot creates an index from an
> item+row+col, but later on tries to retrieve the id from the index. The
> pointer and Id don't have any connection between them, so one must be
> consistent by either using the id or the pointer but never mix them.
>
The model retrieves an item by calling index.internalId() in most calls
as far as I can see. internalId() is not documented in depth (what is
it? Is it
guaranteed to be unique? If yes, for how long?).
>>> client calls model.index(row,col)
>> atatch pointer to parent python object to
>> index and return index
>>>> Its not the parent, but the current item for which the index is created
> normally. If you do that you can use internalPointer.
>
The current item gets its parent item assigned as pointer for use
in model.parent() as far as I can see.
parent = self.item_dict[index.internalId()]
>>> Qt calls model.parent() and maybe queries other indices
>> do something with pointer(s)
>>>> No, Qt doesn't do anything with the internal pointers, or do you mean
> inside parent()? If so, yes the index that is given to parent will have
> its internalPointer set properly when you did the above thing, i.e.
> createIndex(row,col,object)
>
Misunderstood. Qt does not do anything with the pointers. But it
queries index() or parent() multiple times and the implementation
does something with the pointers to process.
>>> client calls model.item(index)
>> do something with pointer
>>>> Right, and the client gets the index right before this call, so the
> index' internalPointer or Id must be valid. If its not something is very
> broken.
>
Not necessarily broken. Just some pointer madness ;-) Qt does not
guarantee anything regarding these pointers ...or indices when it comes
to that.
>>> Somewhere in between these calls the pointer may get lost
>> and you may access an arbitrary memory location or get an index error.
>>>> No, as long as the object that you gave to createIndex is still
> referenced somewhere in your application the internalPointer will still
> be the valid object.
This is waht I would like to assume aswell, but I think this is a wrong
assumption. Your python object may be alive, but the index may point to
anywhere (for example to the refcount object in your traceback).
Most frameworks do it like this: keep a list of pointers and retrieve
items on demand from this list (whatever). Maybe that's why I expected
Qt do allow for the same processing. But the list is useless unless
someone guarantess that indices don't become invalid over time.
You may well pass arbitrary mem locations in the call to
self.items_dict[index.internalId()].
> Thats why you need a list or dict of objects you
> already created (or create a second tree with those objects like the
> simpletreemodel in the PyQt4 examples). As I said earlier what the Qt
> views do internally doesn't concern us here, we can assume they do
> something along this if they need an index:
>> index = model.index(row,col,parent)
> data = model.data(index, role)
>> So the model can assume that every QModelIndex it gets was just created
> a few milli or microseconds ago by a call to index(). If the view wants
> to do caching, it needs to take special care to invalidate indexes in
> the model that are no longer valid. This is possible by connecting to
> the various signals a model sends out (rowsAboutToBeRemoved,
> layoutChanged, reset and so on). And thats also the reason why a model
> always has to call beginXXXRows/endXXXRows, to notify the view and
> others.
>
Qt actually does much more. There may be dozens off calls to parent()
index() (...) in between two client calls.
++ rowsAboutToBeRemoved() is nowhere documented to cache indices.
>>> I guess all comes down to the interpretation of the word "emidiate" in
>> "indices are intended for emidiate use". I may be wrong, but that's
>> how I
>> figured it out for myself.
>>>> See above, generally you're assumed to retrieve an index first via the
> index() function and then do your computations with it. However it is
> possible to cache indices as long as care is taken that you forget about
> cached indices once the model has changed.
>> Andreas
>>
Jürgen
More information about the Eric
mailing list
‘She has never mentioned her father to me. Was he—well, the sort of man whom the County Club would not have blackballed?’ "We walked by the side of our teams or behind the wagons, we slept on the ground at night, we did our own cooking, we washed our knives by sticking them into the ground rapidly a few times, and we washed our plates with sand and wisps of grass. When we stopped, we arranged our wagons in a circle, and thus formed a 'corral,' or yard, where we drove our oxen to yoke them up. And the corral was often very useful as a fort, or camp, for defending ourselves against the Indians. Do you see that little hollow down there?" he asked, pointing to a depression in the ground a short distance to the right of the train. "Well, in that hollow our wagon-train was kept three days and nights by the Indians. Three days and nights they stayed around, and made several attacks. Two of our men were killed and three were wounded by their arrows, and others had narrow escapes. One arrow hit me on the throat, but I was saved by the knot of my neckerchief, and the point only tore the skin a little. Since that time I have always had a fondness for large neckties. I don't know how many of the Indians we killed, as they carried off their dead and wounded, to save them from being scalped. Next to getting the scalps of their enemies, the most important thing with the Indians is to save their own. We had several fights during our journey, but that one was the worst. Once a little party of us were surrounded in a small 'wallow,' and had a tough time to defend ourselves successfully. Luckily for us, the Indians had no fire-arms then, and their bows and arrows were no match for our rifles. Nowadays they are well armed, but there are[Pg 41] not so many of them, and they are not inclined to trouble the railway trains. They used to do a great deal of mischief in the old times, and many a poor fellow has been killed by them." As dusk came on nearly the whole population of Maastricht, with all their temporary guests, formed an endless procession and went to invoke God's mercy by the Virgin Mary's intercession. They went to Our Lady's Church, in which stands the miraculous statue of Sancta Maria Stella Maris. The procession filled all the principal streets and squares of the town. I took my stand at the corner of the Vrijthof, where all marched past me, men, women, and children, all praying aloud, with loud voices beseeching: "Our Lady, Star of the Sea, pray for us ... pray for us ... pray for us ...!" It had not occurred to her for some hours after Mrs. Campbell had told her of Landor's death that she was free now to give herself to Cairness. She had gasped, indeed, when she did remember it, and had put the thought away, angrily and self-reproachfully. But it returned now, and she felt that she might cling to it. She had been grateful, and she had been faithful, too.[Pg 286] She remembered only that Landor had been kind to her, and forgot that for the last two years she had borne with much harsh coldness, and with a sort of contempt which she felt in her unanalyzing mind to have been entirely unmerited. Gradually she raised herself until she sat quite erect by the side of the mound, the old exultation of her half-wild girlhood shining in her face as she planned the future, which only a few minutes before had seemed so hopeless. After he had gloated over Sergeant Ramsey, Shorty got his men into the road ready to start. Si placed himself in front of the squad and deliberately loaded his musket in their sight. Shorty took his place in the rear, and gave out: The groups about each gun thinned out, as the shrieking fragments of shell mowed down man after man, but the rapidity of the fire did not slacken in the least. One of the Lieutenants turned and motioned with his saber to the riders seated on their horses in the line of limbers under the cover of the slope. One rider sprang from each team and ran up to take the place of men who had fallen. "As long as there's men and women in the world, the men 'ull be top and the women bottom." Then, in the house, the little girls were useful. Mrs. Backfield was not so energetic as she used to be. She had never been a robust woman, and though her husband's care had kept her well and strong, her frame was not equal to Reuben's demands; after fourteen years' hard labour, she suffered from rheumatism, which though seldom acute, was inclined to make her stiff and slow. It was here that Caro and Tilly came in, and Reuben began to appreciate his girls. After all, girls were needed in a house—and as for young men and marriage, their father could easily see that such follies did not spoil their usefulness or take them from him. Caro and Tilly helped their grandmother in all sorts of ways—they dusted, they watched pots, they shelled peas and peeled potatoes, they darned house-linen, they could even make a bed between them. HoME一级毛片视频免费公开
ENTER NUMBET 0018www.99ooxx.com.cn www.wtzl.com.cn gdgsyp.com.cn bjyxjy.com.cn www.dlcs888.com.cn www.barosin.com.cn adacore.com.cn cetra.com.cn www.ccpitecc.com.cn www.datamen.com.cn