From a943e0ae741115fbdd72b7ecfa7702f90ad0890b Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Mon, 5 Oct 2009 11:46:29 +0200 Subject: Fix display of rounded Rectangles with border and odd radius. Due to a rounding issue the sum of the margins was larger than the pixmap size, causing qDrawBorderPixmap to only draw the corners and leaving the sides and center blank. --- src/declarative/fx/qfxrect.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index 0648ac4..ea17452 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -427,14 +427,15 @@ void QFxRect::drawRect(QPainter &p) int offset = 0; const int pw = d->pen && d->pen->isValid() ? (d->pen->width()+1)/2*2 : 0; + const int realpw = d->pen && d->pen->isValid() ? d->pen->width() : 0; if (d->radius > 0) { generateRoundedRect(); //### implicit conversion to int - offset = int(d->radius+1.5+pw); + offset = int(d->radius+realpw+1); } else { generateBorderedRect(); - offset = pw+1; + offset = realpw+1; } //basically same code as QFxImage uses to paint sci images @@ -457,6 +458,8 @@ void QFxRect::drawRect(QPainter &p) ySide = yOffset * 2; } + Q_ASSERT(d->rectImage.width() >= 2*xOffset + 1); + Q_ASSERT(d->rectImage.height() >= 2*yOffset + 1); QMargins margins(xOffset, yOffset, xOffset, yOffset); QTileRules rules(Qt::StretchTile, Qt::StretchTile); qDrawBorderPixmap(&p, QRect(-pw/2, -pw/2, width()+pw, height()+pw), margins, d->rectImage, d->rectImage.rect(), margins, rules); -- cgit v0.12