<br><br><div class="gmail_quote">On Thu, Nov 19, 2009 at 9:22 AM, Justin Talbot <span dir="ltr"><<a href="mailto:justintalbot@gmail.com">justintalbot@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><div></div><div class="h5">On Thu, Nov 19, 2009 at 8:54 AM, Michael Lawrence <<a href="mailto:lawremi@gmail.com">lawremi@gmail.com</a>> wrote:<br>
><br>
><br>
> On Thu, Nov 19, 2009 at 4:15 AM, Deepayan Sarkar <<a href="mailto:deepayan.sarkar@gmail.com">deepayan.sarkar@gmail.com</a>><br>
> wrote:<br>
>><br>
>> On Wed, Nov 18, 2009 at 2:49 PM, Deepayan Sarkar<br>
>> <<a href="mailto:deepayan.sarkar@gmail.com">deepayan.sarkar@gmail.com</a>> wrote:<br>
>> > On Wed, Nov 18, 2009 at 1:46 PM, Deepayan Sarkar<br>
>> > <<a href="mailto:deepayan.sarkar@gmail.com">deepayan.sarkar@gmail.com</a>> wrote:<br>
>> >> Any idea what's going wrong here?<br>
>> >><br>
>> >> ### Just code:<br>
>> >><br>
>> >> library(qtbase)<br>
>> >><br>
>> >> gscene <- Qt$QGraphicsScene()<br>
>> >> rtxt <- gscene$addText("some text")<br>
>> >> rtxt<br>
>> >> (rtxt$toPlainText()) ## fine<br>
>> ><br>
>> > And as a confirmation that the <QList> thing is not a problem, I get:<br>
>> ><br>
>> >> item0 <- gscene$itemAt(0, 0)<br>
>> >> item0<br>
>> > <environment: 0x9e21428><br>
>> > attr(,"class")<br>
>> > [1] "QGraphicsTextItem" "QObject" "QGraphicsItem"<br>
>> > [4] "UserDefinedDatabase" "environment"<br>
>> >> item0$toPlainText()<br>
>> ><br>
>> > *** caught segfault ***<br>
>><br>
>> Other QGraphicsItem-s seem fine, so it must be the multiple<br>
>> inheritance (QObject+QGraphicsItem) problem of QGraphicsTextItem<br>
>> again. Given that rtxt works but item0 doesn't, maybe it's a coercion<br>
>> problem somewhere in the wrapping stage?<br>
>><br>
><br>
> Everything method invocation fails with item0. The weird thing is that the<br>
> environments are different. Every C++ pointer should have the same<br>
> environment, and this holds true for the other QGraphicsItem types. This<br>
> indicates that the pointer being returned by itemAt() and items() is<br>
> incorrect.<br>
><br>
> Just checked it, and it looks like the pointer retrieved by e.g. itemAt()<br>
> points 8 bytes higher than the one from addText(). This happens at the Smoke<br>
> level, but looking at their wrappers reveals nothing. Yes, they are casting<br>
> to different types, (QGraphicsTextItem *) vs (QGraphicsItem *), but that<br>
> shouldn't change the value of the pointer, should it? The same error happens<br>
> for addWidget() and its QGraphicsProxyWidget return value. So yes it seems<br>
> like a multiple inheritance issue, but I don't understand how a simple cast<br>
> could cause this. Maybe it's just another C++ surprise?<br>
><br>
>><br>
>> -Deepayan<br>
>> _______________________________________________<br>
>> Qtinterfaces-devel mailing list<br>
>> <a href="mailto:Qtinterfaces-devel@lists.r-forge.r-project.org">Qtinterfaces-devel@lists.r-forge.r-project.org</a><br>
>><br>
>> <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>
><br>
><br>
> _______________________________________________<br>
> Qtinterfaces-devel mailing list<br>
> <a href="mailto:Qtinterfaces-devel@lists.r-forge.r-project.org">Qtinterfaces-devel@lists.r-forge.r-project.org</a><br>
> <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>
><br>
><br>
<br>
</div></div>I haven't looked at this problem, but casting can change the pointer's<br>
value in C++ when there's multiple inheritance. This is due to C++'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'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->cast(). I'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>