Ensure that Canvas has the correct size with complex bindings.
authorMitch Curtis <mitch.curtis@theqtcompany.com>
Tue, 27 Jan 2015 17:09:56 +0000 (18:09 +0100)
committerMitch Curtis <mitch.curtis@digia.com>
Wed, 28 Jan 2015 11:54:41 +0000 (11:54 +0000)
commitfea8c9026def98748f700e33e9fb41249be2b3f2
tree7cd61251f12d1f083eaa58576e256c757c6092c9
parentdd017ee946aaa7f968aa844a54b394f88109c150
Ensure that Canvas has the correct size with complex bindings.

When a Canvas is a child of an item with certain width and height
values (as described in the bug report), it won't paint correctly.

For example, the order of events might occur like so:

1. Canvas width set to 1
2. Canvas height set to 1
3. Canvas width set to 32, which causes the height to also be set to 32

Every size change causes QQuickCanvasItem::geometryChanged() to be
called, but the third event above causes it to be called recursively,
such that the most nested call results in the size being 32x32, but
then the execution returns to the first call and 32x1 is used instead,
overwriting the correct size.

We fix this by setting the new canvas size to width() and height(),
ignoring the recursion and instead using the latest size of the item.

Change-Id: Iebbcbfaa3217319b32b97f6b68f7a8af197a0e89
Task-number: QTBUG-42878
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
src/quick/items/context2d/qquickcanvasitem.cpp
tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml