From d91eb7728beea99eb347293c89500cfa03814208 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 12 Jan 2011 14:21:59 +1000 Subject: Don't use implicitSize when calculating implicit size Width/height ended up getting trapped at <0 in this fillMode if only one of witdh/height was explicit. Task-number: QTBUG-16389 Reviewed-by: Michael Brasser --- src/declarative/graphicsitems/qdeclarativeimage.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index 68a1ecb..af9fc0b 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -386,14 +386,16 @@ void QDeclarativeImage::updatePaintedGeometry() if (d->fillMode == PreserveAspectFit) { if (!d->pix.width() || !d->pix.height()) return; - qreal widthScale = width() / qreal(d->pix.width()); - qreal heightScale = height() / qreal(d->pix.height()); + int effectiveHeight = heightValid() ? height() : d->pix.height(); + int effectiveWidth = widthValid() ? width() : d->pix.width(); + qreal widthScale = effectiveWidth / qreal(d->pix.width()); + qreal heightScale = effectiveHeight / qreal(d->pix.height()); if (widthScale <= heightScale) { - d->paintedWidth = width(); + d->paintedWidth = effectiveWidth; d->paintedHeight = widthScale * qreal(d->pix.height()); } else if(heightScale < widthScale) { d->paintedWidth = heightScale * qreal(d->pix.width()); - d->paintedHeight = height(); + d->paintedHeight = effectiveHeight; } if (widthValid() && !heightValid()) { setImplicitHeight(d->paintedHeight); -- cgit v0.12