diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-09-28 08:00:29 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-09-28 12:11:51 +0000 |
commit | 797d3ca58c1487b1abdba051756948f29342c28c (patch) | |
tree | 37b02ac609b96105916e7eba53487b53d4564b8c | |
parent | 97e25d198d6bcd219c0076947163333897c192f2 (diff) |
QQuickPaddedRectangle: prevent negative width and height
If the padding is larger than the available size, the rectangle node
should not be given a negative size, because the node is still rendered
and it results to undesired rendering artifacts.
Change-Id: I082649badb04fe33dbea2ca2c4efcf0f179f41a8
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r-- | src/quickcontrols2/qquickpaddedrectangle.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/quickcontrols2/qquickpaddedrectangle.cpp b/src/quickcontrols2/qquickpaddedrectangle.cpp index 3555d6d7..f7088d54 100644 --- a/src/quickcontrols2/qquickpaddedrectangle.cpp +++ b/src/quickcontrols2/qquickpaddedrectangle.cpp @@ -200,7 +200,10 @@ QSGNode *QQuickPaddedRectangle::updatePaintNode(QSGNode *node, UpdatePaintNodeDa m.translate(left, top); transformNode->setMatrix(m); - rectNode->setRect(boundingRect().adjusted(0, 0, -left-right, -top-bottom)); + qreal w = qMax<qreal>(0.0, width() -left-right); + qreal h = qMax<qreal>(0.0, height() -top-bottom); + + rectNode->setRect(QRectF(0, 0, w, h)); rectNode->update(); } } |