diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2011-01-12 04:21:59 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2011-01-12 04:21:59 (GMT) |
commit | d91eb7728beea99eb347293c89500cfa03814208 (patch) | |
tree | 30db0340e5e4eaf3a82f02f5d56fde8c48cbe24e /src/declarative | |
parent | 44fa2974a15657aa7e37489670164587311e0007 (diff) | |
download | Qt-d91eb7728beea99eb347293c89500cfa03814208.zip Qt-d91eb7728beea99eb347293c89500cfa03814208.tar.gz Qt-d91eb7728beea99eb347293c89500cfa03814208.tar.bz2 |
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
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativeimage.cpp | 10 |
1 files 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); |