Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

QML Canvas causing crash

$
0
0
My application is essentially a dynamically created set of pages (similar to PageStack) with a ListView as one of the contained items. I’ve was using a Canvas as the ListView highlight component, which works great until a page is destroyed (or a previously painted page is repainted, not sure which). I’m not entirely sure what is going on here and could use some ideas. My ListView looks something like: ListView {         highlight: Canvas {             id: canvas             antialiasing: true             renderTarget: Canvas.Image               onPaint: {                 var ctx = canvas.getContext('2d');                 ctx.save()                   ctx.fillStyle = "#555555"                 // Draw shapes                 ctx.clearRect(0,0,canvas.width, canvas.height);                 ctx.beginPath();                 ctx.moveTo(0,0)                 ctx.lineTo(0, canvas.height)                 ctx.lineTo(canvas.width*.93, canvas.height)                 ctx.lineTo(canvas.width, canvas.height/2)                 ctx.lineTo(canvas.width*.93, 0)                 ctx.lineTo(canvas.width*.93, 0)                 ctx.lineTo(0, 0)                 ctx.fill()                 ctx.restore()             }         }           model: myModel         delegate: Text {             text: modelText        } } I’ve noticed that I can comment out everything in the onPaint handler EXCEPT the getContext line, I still get the crash, so I’m assuming something about getContext is going wrong. Any help or ideas to debug this would be appreciated, thanks.

Viewing all articles
Browse latest Browse all 4972

Trending Articles