QmlProfiler: Don't use the canvas context if it isn't ready

The documentation indicates that onPaint can actually be called
while the context isn't ready.

Change-Id: I32d861e016e5e990f3d940a35ec28956902041ba
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
Ulf Hermann
2014-02-25 17:08:26 +01:00
parent 9d1a1d2cdf
commit 0b6b67ca07
3 changed files with 6 additions and 0 deletions

View File

@@ -92,6 +92,8 @@ Canvas {
// ***** slots // ***** slots
onPaint: { onPaint: {
if (context === null)
return; // canvas isn't ready
Plotter.qmlProfilerModelProxy = qmlProfilerModelProxy; Plotter.qmlProfilerModelProxy = qmlProfilerModelProxy;
if (dataReady) { if (dataReady) {
Plotter.plot(canvas, context, region); Plotter.plot(canvas, context, region);

View File

@@ -49,6 +49,8 @@ Canvas {
} }
onPaint: { onPaint: {
if (context === null)
return; // canvas isn't ready
context.fillStyle = "white"; context.fillStyle = "white";
context.fillRect(0, 0, width, height); context.fillRect(0, 0, width, height);

View File

@@ -47,6 +47,8 @@ Canvas {
onYChanged: requestPaint() onYChanged: requestPaint()
onPaint: { onPaint: {
if (context === null)
return; // canvas isn't ready
drawBackgroundBars( context, region ); drawBackgroundBars( context, region );
var totalTime = endTime - startTime; var totalTime = endTime - startTime;