[RQt-devel] possible bug in qtbase
Deepayan Sarkar
deepayan.sarkar at gmail.com
Wed Sep 21 04:40:05 CEST 2011
On Wed, Sep 21, 2011 at 3:20 AM, Michael Lawrence
<lawrence.michael at gene.com> wrote:
>
>
> On Tue, Sep 20, 2011 at 12:03 PM, Deepayan Sarkar
> <deepayan.sarkar at gmail.com> wrote:
>>
>> On Tue, Sep 20, 2011 at 8:55 PM, Michael Lawrence
>> <lawrence.michael at gene.com> wrote:
>> > Hi Deepayan,
>> >
>> > Nice to hear you are back into the Qt stuff. I can indeed reproduce
>> > this.
>> > But not anymore, because I've fixed it.
>>
>> Thanks, I can confirm the fix.
>>
>> I've decided to try out a different approach, managing the layout in R
>> as much as possible, and target multiple backends. I'm initially
>> experimenting with QGraphicsView/Scene, and now I'm getting much
>> further with that thanks to your fix. At some point I'll start bugging
>> you about qtpaint as well.
>>
>
> You might want to check out anypaint in the GGobi github. Gabriel Becker
> (DTL's student) has been doing a lot of work on generic (pure R, backend
> agnostic) implementations of things like layout. He's implementing anypaint
> against HTML5/JS in Firefox, via RFirefox. I need to make sure that he is
> committing his stuff back into github.
Seems mostly notImplemented() calls right now.
>> I think there are still problems lurking around. Here is a protection
>> bug: This gives an error because the gc() causes view$scene() to go
>> away.
>>
>> ----
>> library(qtbase)
>>
>> view <- Qt$QGraphicsView()
>> view$size <- qsize(600, 600)
>> view$setScene(Qt$QGraphicsScene())
>> ## class(view$scene())
>> gc()
>> view$scene() # NULL
>> view$scene()$clear()
>> ----
>>
>> If I uncomment the 'class(view$scene())' then things are OK.
>>
>
> This is just Qt. Neither R nor QGraphicsView keep a reference to the scene.
> This is why qtpaint sets the parent of the scene to the view, if it does not
> already have a parent.
So having an R reference like so
scene <- Qt$QGraphicsScene()
view$setScene(scene)
should be safe?
>> In a more realistic example involving QGraphicsScene (that I haven't
>> been able to simplify yet), having a gc() keeps things sane, and not
>> having it leads to errors similar to the ones before, e.g.,
>>
>> Error in qinvokeStatic(cl, basename, ...) :
>> Expected an instance of type 'QColor', not 'QGraphicsLineItem'
>> Calls: print ... is -> qbrush -> <Anonymous> -> qinvokeStatic -> .Call
>>
>
> Looking forward to that simplified example.
Here goes. Adding the gc() makes the whole thing work fine. The
trivial qpen() call is required.
#----
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)
}
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
More information about the Qtinterfaces-devel
mailing list