<br><br><div class="gmail_quote">On Thu, Nov 19, 2009 at 9:22 AM, Justin Talbot <span dir="ltr">&lt;<a href="mailto:justintalbot@gmail.com">justintalbot@gmail.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;">
<div><div></div><div class="h5">On Thu, Nov 19, 2009 at 8:54 AM, Michael Lawrence &lt;<a href="mailto:lawremi@gmail.com">lawremi@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt; On Thu, Nov 19, 2009 at 4:15 AM, Deepayan Sarkar &lt;<a href="mailto:deepayan.sarkar@gmail.com">deepayan.sarkar@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; On Wed, Nov 18, 2009 at 2:49 PM, Deepayan Sarkar<br>
&gt;&gt; &lt;<a href="mailto:deepayan.sarkar@gmail.com">deepayan.sarkar@gmail.com</a>&gt; wrote:<br>
&gt;&gt; &gt; On Wed, Nov 18, 2009 at 1:46 PM, Deepayan Sarkar<br>
&gt;&gt; &gt; &lt;<a href="mailto:deepayan.sarkar@gmail.com">deepayan.sarkar@gmail.com</a>&gt; wrote:<br>
&gt;&gt; &gt;&gt; Any idea what&#39;s going wrong here?<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; ### Just code:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; library(qtbase)<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; gscene &lt;- Qt$QGraphicsScene()<br>
&gt;&gt; &gt;&gt; rtxt &lt;- gscene$addText(&quot;some text&quot;)<br>
&gt;&gt; &gt;&gt; rtxt<br>
&gt;&gt; &gt;&gt; (rtxt$toPlainText()) ## fine<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; And as a confirmation that the &lt;QList&gt; thing is not a problem, I get:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; item0 &lt;- gscene$itemAt(0, 0)<br>
&gt;&gt; &gt;&gt; item0<br>
&gt;&gt; &gt; &lt;environment: 0x9e21428&gt;<br>
&gt;&gt; &gt; attr(,&quot;class&quot;)<br>
&gt;&gt; &gt; [1] &quot;QGraphicsTextItem&quot;   &quot;QObject&quot;             &quot;QGraphicsItem&quot;<br>
&gt;&gt; &gt; [4] &quot;UserDefinedDatabase&quot; &quot;environment&quot;<br>
&gt;&gt; &gt;&gt; item0$toPlainText()<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;  *** caught segfault ***<br>
&gt;&gt;<br>
&gt;&gt; Other QGraphicsItem-s seem fine, so it must be the multiple<br>
&gt;&gt; inheritance (QObject+QGraphicsItem) problem of  QGraphicsTextItem<br>
&gt;&gt; again. Given that rtxt works but item0 doesn&#39;t, maybe it&#39;s a coercion<br>
&gt;&gt; problem somewhere in the wrapping stage?<br>
&gt;&gt;<br>
&gt;<br>
&gt; Everything method invocation fails with item0. The weird thing is that the<br>
&gt; environments are different. Every C++ pointer should have the same<br>
&gt; environment, and this holds true for the other QGraphicsItem types. This<br>
&gt; indicates that the pointer being returned by itemAt() and items() is<br>
&gt; incorrect.<br>
&gt;<br>
&gt; Just checked it, and it looks like the pointer retrieved by e.g. itemAt()<br>
&gt; points 8 bytes higher than the one from addText(). This happens at the Smoke<br>
&gt; level, but looking at their wrappers reveals nothing. Yes, they are casting<br>
&gt; to different types, (QGraphicsTextItem *) vs (QGraphicsItem *), but that<br>
&gt; shouldn&#39;t change the value of the pointer, should it? The same error happens<br>
&gt; for addWidget() and its QGraphicsProxyWidget return value. So yes it seems<br>
&gt; like a multiple inheritance issue, but I don&#39;t understand how a simple cast<br>
&gt; could cause this. Maybe it&#39;s just another C++ surprise?<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; -Deepayan<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Qtinterfaces-devel mailing list<br>
&gt;&gt; <a href="mailto:Qtinterfaces-devel@lists.r-forge.r-project.org">Qtinterfaces-devel@lists.r-forge.r-project.org</a><br>
&gt;&gt;<br>
&gt;&gt; <a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/qtinterfaces-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/qtinterfaces-devel</a><br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Qtinterfaces-devel mailing list<br>
&gt; <a href="mailto:Qtinterfaces-devel@lists.r-forge.r-project.org">Qtinterfaces-devel@lists.r-forge.r-project.org</a><br>
&gt; <a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/qtinterfaces-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/qtinterfaces-devel</a><br>
&gt;<br>
&gt;<br>
<br>
</div></div>I haven&#39;t looked at this problem, but casting can change the pointer&#39;s<br>
value in C++ when there&#39;s multiple inheritance. This is due to C++&#39;s<br>
virtual function table mechanism for inheritance. For more info see<br>
section 4.4 of <a href="http://www-plan.cs.colorado.edu/diwan/class-papers/mi.pdf" target="_blank">http://www-plan.cs.colorado.edu/diwan/class-papers/mi.pdf</a><br>
<font color="#888888"><br></font></blockquote><div><br>Alrighty then. Right now, we&#39;re using the introspection information of the QGraphicsItem to resolve the class from the QGraphicsItem returned by itemAt() down to QGraphicsTextItem (so that we can use methods like toPlainText()).  But the pointer is still of QGraphicsItem type, so must be cast appropriately via smoke-&gt;cast(). I&#39;ll fix this tonight.<br>
 <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><font color="#888888">
Justin<br>
</font></blockquote></div><br>