From: Gunnar Sletta Date: Tue, 27 Sep 2011 15:04:03 +0000 (+0200) Subject: Don't crash when Image.source change X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=9a8466839b030a4ffebf74a813737d7cc55aa1d0;p=konrad%2Fqtdeclarative.git Don't crash when Image.source change QDeclarativePixmap::clear() may result in the texture being scheduled for deletion, so we need to make sure that our texture provider is updated properly whenever the source changes. Change-Id: Ie21c6fcba4b0cd438250dc4c263b513060cc026e Reviewed-on: http://codereview.qt-project.org/5673 Reviewed-by: Qt Sanity Bot Reviewed-by: Aaron Kennedy --- diff --git a/src/declarative/items/qsgimage.cpp b/src/declarative/items/qsgimage.cpp index 8cf8599..92b454b 100644 --- a/src/declarative/items/qsgimage.cpp +++ b/src/declarative/items/qsgimage.cpp @@ -704,6 +704,10 @@ void QSGImage::pixmapChange() QSGImageBase::pixmapChange(); updatePaintedGeometry(); d->pixmapChanged = true; + + // Make sure we update the texture provider when the image has changed. + if (d->provider) + update(); } QSGImage::VAlignment QSGImage::verticalAlignment() const diff --git a/src/declarative/items/qsgimagebase.cpp b/src/declarative/items/qsgimagebase.cpp index 5c6334d..0c08010 100644 --- a/src/declarative/items/qsgimagebase.cpp +++ b/src/declarative/items/qsgimagebase.cpp @@ -208,6 +208,7 @@ void QSGImageBase::load() if (d->cache) options |= QDeclarativePixmap::Cache; d->pix.clear(this); + pixmapChange(); d->pix.load(qmlEngine(this), d->url, d->explicitSourceSize ? sourceSize() : QSize(), options); if (d->pix.isLoading()) {