summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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: