summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2010-02-03 06:39:00 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2010-02-03 06:39:00 (GMT)
commit6abdaa41a3f40238e8a60b80b9ac55a694181e11 (patch)
tree57693683532a53e2f81fcbb796f24e914bbecf21
parentdad8d1ba685657db03c066979692f097c6f3be0c (diff)
downloadQt-6abdaa41a3f40238e8a60b80b9ac55a694181e11.zip
Qt-6abdaa41a3f40238e8a60b80b9ac55a694181e11.tar.gz
Qt-6abdaa41a3f40238e8a60b80b9ac55a694181e11.tar.bz2
update Image.paintedWidth and Image.paintedHeight when the source changes
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsimage.cpp3
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsimage_p.h2
2 files changed, 5 insertions, 0 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsimage.cpp b/src/declarative/graphicsitems/qmlgraphicsimage.cpp
index ad43027..a1e8c17 100644
--- a/src/declarative/graphicsitems/qmlgraphicsimage.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsimage.cpp
@@ -128,6 +128,7 @@ QML_DEFINE_TYPE(Qt,4,6,Image,QmlGraphicsImage)
QmlGraphicsImage::QmlGraphicsImage(QmlGraphicsItem *parent)
: QmlGraphicsImageBase(*(new QmlGraphicsImagePrivate), parent)
{
+ connect(this, SIGNAL(sourceChanged(QUrl)), this, SLOT(updatePaintedGeometry()));
}
QmlGraphicsImage::QmlGraphicsImage(QmlGraphicsImagePrivate &dd, QmlGraphicsItem *parent)
@@ -270,6 +271,8 @@ void QmlGraphicsImage::updatePaintedGeometry()
if (d->fillMode == PreserveAspectFit) {
qreal widthScale = width() / qreal(d->pix.width());
qreal heightScale = height() / qreal(d->pix.height());
+ if (!d->pix.width() || !d->pix.height())
+ return;
if (widthScale <= heightScale) {
d->paintedWidth = width();
d->paintedHeight = widthScale * qreal(d->pix.height());
diff --git a/src/declarative/graphicsitems/qmlgraphicsimage_p.h b/src/declarative/graphicsitems/qmlgraphicsimage_p.h
index 36066e1..dde5d79 100644
--- a/src/declarative/graphicsitems/qmlgraphicsimage_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsimage_p.h
@@ -86,6 +86,8 @@ Q_SIGNALS:
protected:
QmlGraphicsImage(QmlGraphicsImagePrivate &dd, QmlGraphicsItem *parent);
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
+
+protected Q_SLOTS:
void updatePaintedGeometry();
private: