summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-03-17 07:10:56 (GMT)
committerMartin Jones <martin.jones@nokia.com>2011-03-17 07:17:43 (GMT)
commit695a39410c8ce186a2ce78cef51093c55fc32643 (patch)
treeb33d7c5f1f0e24b1180fcbdb989a47e38f825868 /src
parentcb0b93e3ef107b8a47445c926753b6bcf07b796d (diff)
downloadQt-695a39410c8ce186a2ce78cef51093c55fc32643.zip
Qt-695a39410c8ce186a2ce78cef51093c55fc32643.tar.gz
Qt-695a39410c8ce186a2ce78cef51093c55fc32643.tar.bz2
Image.PreserveAspectFit has unexpected effect on Image's sourceSize
The sourceSize should always be the size of the image, unless set otherwise. When calculating the size of an image with Image.PreserveAspectFit set the natural image size should be used for the calculation if no size has been set explicitly. Change-Id: I104b7d1c3c16aa5b4fc98b1f9078ed8ae997cf69 Task-number: QTBUG-16389 Reviewed-by: Joona Petrell
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage.cpp10
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase.cpp2
2 files changed, 7 insertions, 5 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp
index ec20200..ed5d5fc 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp
@@ -389,14 +389,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());
+ qreal w = widthValid() ? width() : d->pix.width();
+ qreal widthScale = w / qreal(d->pix.width());
+ qreal h = heightValid() ? height() : d->pix.height();
+ qreal heightScale = h / qreal(d->pix.height());
if (widthScale <= heightScale) {
- d->paintedWidth = width();
+ d->paintedWidth = w;
d->paintedHeight = widthScale * qreal(d->pix.height());
} else if(heightScale < widthScale) {
d->paintedWidth = heightScale * qreal(d->pix.width());
- d->paintedHeight = height();
+ d->paintedHeight = h;
}
if (widthValid() && !heightValid()) {
setImplicitHeight(d->paintedHeight);
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
index 471c87f..2de3ba0 100644
--- a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
@@ -130,7 +130,7 @@ QSize QDeclarativeImageBase::sourceSize() const
int width = d->sourcesize.width();
int height = d->sourcesize.height();
- return QSize(width != -1 ? width : implicitWidth(), height != -1 ? height : implicitHeight());
+ return QSize(width != -1 ? width : d->pix.width(), height != -1 ? height : d->pix.height());
}
bool QDeclarativeImageBase::cache() const