<div class="gmail_quote">On Wed, Jun 3, 2009 at 2:20 PM, Darren Dale <span dir="ltr"><<a href="mailto:dsdale24@gmail.com">dsdale24@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="gmail_quote"><div><div></div><div class="h5">On Wed, Jun 3, 2009 at 12:08 PM, Phil Thompson <span dir="ltr"><<a href="mailto:phil@riverbankcomputing.com" target="_blank">phil@riverbankcomputing.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Wed, 03 Jun 2009 17:37:29 +0200, "V. Armando Solé" <<a href="mailto:sole@esrf.fr" target="_blank">sole@esrf.fr</a>><br>
wrote:<br>
<div><div></div><div>> Hello,<br>
><br>
> The problem can be solved as shown below.<br>
><br>
> It seems the linux 32 bit implementation gets confused in<br>
> createIndex(row, column, a) when a is not an integer but a long. With<br>
> small values of a (10, 100, 1000), the indexId() method returns the<br>
> supplied value.<br>
><br>
> The solution is to call createIndex(row, column, a) with a being a<br>
> python object and not its id. The indexId() method can be masked with a<br>
> 32 bit mask if it returns a negative value. I have only found that<br>
> misbehavior under linux 32bit. Windows XP and linux 64-bit behave<br>
properly.<br>
><br>
> Thanks for your time,<br>
><br>
> Armando<br>
><br>
> import PyQt4.Qt as qt<br>
> import random<br>
> import sys<br>
><br>
> mask = 0xFFFFFFFF<br>
><br>
> class Model(qt.QAbstractItemModel):<br>
> def index(self, row, column, parent):<br>
> a=[random.random()]<br>
> index = self.createIndex(row, column, a)<br>
> print "Next two values should be the same"<br>
> returned = index.internalId()<br>
> if returned < 0:<br>
> returned = returned & mask<br>
> print "indexInternalId = ", returned<br>
> print "id(a) = ", id(a)<br>
> print "Forcing to be the same with a 32 bit mask"<br>
> print "indexInternalId = ", index.internalId() & mask<br>
> print "id(a) = ", id(a) & mask<br>
> return index<br>
><br>
> if __name__ == "__main__":<br>
> app = qt.QApplication([])<br>
> w = Model()<br>
> w.index(0,0,None)<br>
<br>
</div></div>Could you see if the problem goes away if you change qabstractitemmodel.sip<br>
so that...<br>
<br>
QModelIndex createIndex(int arow, int acolumn, int aid) const;<br>
<br>
...is replaced by...<br>
<br>
QModelIndex createIndex(int arow, int acolumn, quint32 aid) const;<br>
<font color="#888888"></font></blockquote></div></div><div><br>I applied this change to the 20090601 snapshot. Executive summary: when I check different data types, I can still find places where the two id's do not agree. I find disagreement with the mask applied and without:<br>
<br>When I run the script I posted, I get output like:<div class="im"><br><br>Next two values should be the same<br></div>indexInternalId = 1849945336 <br>id(a) = 139691366280440<br><br>If I apply Armando's mask, I get:<div class="im">
<br><br>Next two values should be the same<br></div>
indexInternalId = 12719168<br>id(a) = 12719168<br><br>If I remove the mask and instead do "a=[numpy.uint32(random.random())]", I get ouput like:<div class="im"><br><br>Next two values should be the same<br></div>
indexInternalId = 12719168<br>
id(a) = 12719168<br><br>Still without the mask, if I do "a=[numpy.int64(random.random())]":<div class="im"><br><br>Next two values should be the same<br></div>indexInternalId = 12719168<br>id(a) = 12719168<br>
<br>And finally, with Armando's mask and with "a=[numpy.int64(random.random())]":<div class="im"><br>
<br>Next two values should be the same<br></div>indexInternalId = 110072896<br>id(a) = 139754050917440<br></div></div></blockquote><div><br>There was a bug report, it has been marked "won't fix": <a href="http://www.qtsoftware.com/developer/task-tracker/index_html?method=entry&id=204226">http://www.qtsoftware.com/developer/task-tracker/index_html?method=entry&id=204226</a> <br>
</div></div>