[RQt-devel] possible bug in qtbase

Michael Lawrence lawrence.michael at gene.com
Wed Sep 21 19:14:58 CEST 2011


Just pushed the fix. Let me know if this screws up something else.

Thanks,
Michael

On Wed, Sep 21, 2011 at 9:07 AM, Deepayan Sarkar
<deepayan.sarkar at gmail.com>wrote:

> On Wed, Sep 21, 2011 at 7:22 PM, Michael Lawrence
> <lawrence.michael at gene.com> wrote:
> >
> >
> > On Tue, Sep 20, 2011 at 9:48 PM, Michael Lawrence <michafla at gene.com>
> wrote:
> >>
> >>
> >> On Tue, Sep 20, 2011 at 7:40 PM, Deepayan Sarkar
>
> [...]
>
> >>> Here goes. Adding the gc() makes the whole thing work fine. The
> >>> trivial qpen() call is required.
> >>>
> >>
> >> Thanks a lot. Will look at this.
> >>
> >>>
> >>> #----
> >>> library(qtbase)
> >>>
> >>> v <- Qt$QGraphicsView()
> >>> v$size <- qsize(300, 300)
> >>> scene <- Qt$QGraphicsScene()
> >>> v$setScene(scene)
> >>> v$show()
> >>>
> >>> doplot <- function(view, scene)
> >>> {
> >>>    ## gc()
> >>>    scene$clear()
> >>>    x <- runif(2, 50, 250)
> >>>    scene$addEllipse(x[1], x[2], 10, 10, qpen())
> >>>    Sys.sleep(0.01)
> >>> }
> >>>
> >
> > The issue is that scene$clear() frees all objects, including the ellipse,
> > but since Qt constructed the QGraphicsEllipseItem, we have no way of
> knowing
> > that it has been freed, and so we cannot clear the pointer out of the
> hash.
> > The fix yesterday made it so that if the R object was garbage collected,
> the
> > pointer would be cleared in this situation. It may be that we can get
> away
> > without adding such pointers to the hash at all, i.e., we would create a
> new
> > wrapper object every time we see them. That will take a lot of thought
> > though about the myriad of consequences.
>
> Makes sense. My first attempt had been replacing view$scene() by a new
> scene each time, and that had no problems.
>
> I will go back to that approach for now.
>
> -Deepayan
>
> >
> > Please stand by.
> >
> > Michael
> >
> >
> >>>
> >>> niter <- 0L
> >>> while (TRUE)
> >>> {
> >>>    doplot(view = v, scene = scene)
> >>>    niter <- niter + 1
> >>>    cat(niter, fill = TRUE)
> >>> }
> >>> #----
> >>>
> >>> I'm usually getting an error within 10 iterations.
> >>>
> >>> -Deepayan
> >>
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/qtinterfaces-devel/attachments/20110921/762733ed/attachment.htm>


More information about the Qtinterfaces-devel mailing list