Just pushed the fix. Let me know if this screws up something else.<br><br>Thanks,<br>Michael<br><br><div class="gmail_quote">On Wed, Sep 21, 2011 at 9:07 AM, Deepayan Sarkar <span dir="ltr"><<a href="mailto:deepayan.sarkar@gmail.com">deepayan.sarkar@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">On Wed, Sep 21, 2011 at 7:22 PM, Michael Lawrence<br>
<div class="im"><<a href="mailto:lawrence.michael@gene.com">lawrence.michael@gene.com</a>> wrote:<br>
><br>
><br>
</div><div class="im">> On Tue, Sep 20, 2011 at 9:48 PM, Michael Lawrence <<a href="mailto:michafla@gene.com">michafla@gene.com</a>> wrote:<br>
>><br>
>><br>
>> On Tue, Sep 20, 2011 at 7:40 PM, Deepayan Sarkar<br>
<br>
</div>[...]<br>
<div class="im"><br>
>>> Here goes. Adding the gc() makes the whole thing work fine. The<br>
>>> trivial qpen() call is required.<br>
>>><br>
>><br>
>> Thanks a lot. Will look at this.<br>
>><br>
>>><br>
>>> #----<br>
>>> library(qtbase)<br>
>>><br>
>>> v <- Qt$QGraphicsView()<br>
>>> v$size <- qsize(300, 300)<br>
>>> scene <- Qt$QGraphicsScene()<br>
>>> v$setScene(scene)<br>
>>> v$show()<br>
>>><br>
>>> doplot <- function(view, scene)<br>
>>> {<br>
>>> ## gc()<br>
>>> scene$clear()<br>
>>> x <- runif(2, 50, 250)<br>
>>> scene$addEllipse(x[1], x[2], 10, 10, qpen())<br>
>>> Sys.sleep(0.01)<br>
>>> }<br>
>>><br>
><br>
> The issue is that scene$clear() frees all objects, including the ellipse,<br>
> but since Qt constructed the QGraphicsEllipseItem, we have no way of knowing<br>
> that it has been freed, and so we cannot clear the pointer out of the hash.<br>
> The fix yesterday made it so that if the R object was garbage collected, the<br>
> pointer would be cleared in this situation. It may be that we can get away<br>
> without adding such pointers to the hash at all, i.e., we would create a new<br>
> wrapper object every time we see them. That will take a lot of thought<br>
> though about the myriad of consequences.<br>
<br>
</div>Makes sense. My first attempt had been replacing view$scene() by a new<br>
scene each time, and that had no problems.<br>
<br>
I will go back to that approach for now.<br>
<font color="#888888"><br>
-Deepayan<br>
</font><div><div></div><div class="h5"><br>
><br>
> Please stand by.<br>
><br>
> Michael<br>
><br>
><br>
>>><br>
>>> niter <- 0L<br>
>>> while (TRUE)<br>
>>> {<br>
>>> doplot(view = v, scene = scene)<br>
>>> niter <- niter + 1<br>
>>> cat(niter, fill = TRUE)<br>
>>> }<br>
>>> #----<br>
>>><br>
>>> I'm usually getting an error within 10 iterations.<br>
>>><br>
>>> -Deepayan<br>
>><br>
><br>
><br>
</div></div></blockquote></div><br>