<div class="gmail_quote">On Wed, Jun 3, 2009 at 12:08 PM, Phil Thompson <span dir="ltr">&lt;<a href="mailto:phil@riverbankcomputing.com">phil@riverbankcomputing.com</a>&gt;</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, &quot;V. Armando Solé&quot; &lt;<a href="mailto:sole@esrf.fr">sole@esrf.fr</a>&gt;<br>
wrote:<br>
<div><div></div><div class="h5">&gt; Hello,<br>
&gt;<br>
&gt; The problem can be solved as shown below.<br>
&gt;<br>
&gt; It seems the linux 32 bit implementation gets confused in<br>
&gt; createIndex(row, column, a) when a is not an integer but a long. With<br>
&gt; small values of a (10, 100, 1000),  the indexId() method returns the<br>
&gt; supplied value.<br>
&gt;<br>
&gt; The solution is to call createIndex(row, column, a) with a being a<br>
&gt; python object and not its id. The indexId() method can be masked with a<br>
&gt; 32 bit mask if it returns a negative value. I have only found that<br>
&gt; misbehavior under linux 32bit. Windows XP and linux 64-bit behave<br>
properly.<br>
&gt;<br>
&gt; Thanks for your time,<br>
&gt;<br>
&gt; Armando<br>
&gt;<br>
&gt; import PyQt4.Qt as qt<br>
&gt; import random<br>
&gt; import sys<br>
&gt;<br>
&gt; mask = 0xFFFFFFFF<br>
&gt;<br>
&gt; class Model(qt.QAbstractItemModel):<br>
&gt;   def index(self, row, column, parent):<br>
&gt;       a=[random.random()]<br>
&gt;       index =  self.createIndex(row, column, a)<br>
&gt;       print &quot;Next two values should be the same&quot;<br>
&gt;       returned = index.internalId()<br>
&gt;       if returned &lt; 0:<br>
&gt;           returned = returned &amp; mask<br>
&gt;       print &quot;indexInternalId = &quot;, returned<br>
&gt;       print &quot;id(a) = &quot;, id(a)<br>
&gt;       print &quot;Forcing to be the same with a 32 bit mask&quot;<br>
&gt;       print &quot;indexInternalId = &quot;, index.internalId() &amp; mask<br>
&gt;       print &quot;id(a) = &quot;, id(a) &amp; mask<br>
&gt;       return index<br>
&gt;<br>
&gt; if __name__ == &quot;__main__&quot;:<br>
&gt;   app = qt.QApplication([])<br>
&gt;   w = Model()<br>
&gt;   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><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&#39;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:<br><br>Next two values should be the same<br>indexInternalId =  1849945336     <br>id(a) =  139691366280440<br><br>If I apply Armando&#39;s mask, I get:<br><br>Next two values should be the same<br>
indexInternalId =  12719168<br>id(a) =  12719168<br><br>If I remove the mask and instead do &quot;a=[numpy.uint32(random.random())]&quot;, I get ouput like:<br><br>Next two values should be the same<br>indexInternalId =  12719168<br>
id(a) =  12719168<br><br>Still without the mask, if I do &quot;a=[numpy.int64(random.random())]&quot;:<br><br>Next two values should be the same<br>indexInternalId =  12719168<br>id(a) =  12719168<br><br>And finally, with Armando&#39;s mask and with &quot;a=[numpy.int64(random.random())]&quot;:<br>
<br>Next two values should be the same<br>indexInternalId =  110072896<br>id(a) =  139754050917440<br><br>Darren<br></div></div>