QQuickItem::geometryChanged(newGeometry, oldGeometry);
- QSizeF newSize = newGeometry.size();
+ // Due to indirect recursion, newGeometry may be outdated
+ // after this call, so we use width and height instead.
+ QSizeF newSize = QSizeF(width(), height());
if (!d->hasCanvasSize && d->canvasSize != newSize) {
d->canvasSize = newSize;
emit canvasSizeChanged();
import QtQuick 2.0
+Item {
+ id: container
+ width: 200
+ height: 200
+
CanvasTestCase {
id:testCase
name: "canvas"
fail(exception.message);
}
}
-}
+ property Component implicitlySizedComponent: Item {
+ implicitWidth: 32
+ implicitHeight: implicitWidth
+ anchors.centerIn: parent
+
+ property alias canvas: canvas
+
+ Canvas {
+ id: canvas
+ width: Math.max(1, Math.min(parent.width, parent.height))
+ height: width
+
+ onPaint: {
+ var ctx = getContext("2d");
+ ctx.reset();
+ ctx.beginPath();
+ ctx.fillRect(0, 0, width, height);
+ }
+ }
+ }
+
+ function test_implicitlySizedParent() {
+ var implicitlySizedItem = implicitlySizedComponent.createObject(container);
+ verify(implicitlySizedItem);
+
+ var xCenter = implicitlySizedItem.width / 2;
+ var yCenter = implicitlySizedItem.height / 2;
+ waitForRendering(implicitlySizedItem);
+ comparePixel(implicitlySizedItem.canvas.context, xCenter, yCenter, 0, 0, 0, 255);
+ }
+}
+}