@pnmrvvtl Looking at the source here (Line 660), the assert occurs when the rect (viz. here the canvas) is not valid. But I tested something similar on Linux and it works. Following is the code:
import QtQuick 2.4
Canvas {
id: root
width: 200
height: 200
property point initialpos : Qt.point(0,0)
property point finalpos: Qt.point(0,0)
property int count : 0
onPaint: {
var ctx = getContext("2d")
ctx.clearRect(0, 0, width, height);
ctx.lineWidth = 2
ctx.strokeStyle = "red"
ctx.beginPath()
ctx.moveTo(initialpos.x,initialpos.y)
ctx.lineTo(finalpos.x,finalpos.y)
ctx.stroke()
ctx.closePath()
}
Timer {
interval: 1000; running: true; repeat: true
onTriggered: {
initialpos = Qt.point(Math.floor(Math.random() * 200) + 1,Math.floor(Math.random() * 200) + 1)
finalpos = Qt.point(Math.floor(Math.random() * 200) + 1,Math.floor(Math.random() * 200) + 1)
root.paint(0,0,root.width,root.height)
root.save("/home/ashish/grab/"+count+++".jpg")
}
}
}
This code just takes snaps of Canvas and save into directory after an interval of 1 sec. This works for me and there is no assert. Also root.requestPaint() instead of root.paint(0,0,root.width,root.height) works even if the Window is minimized.
Can you test it on your system ?