summaryrefslogtreecommitdiffstats
path: root/src/declarative/util/qmlpixmapcache.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-11-19 03:50:43 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-11-19 03:50:43 (GMT)
commitd363016a703f565432d2fd3d84cea4e179c79995 (patch)
tree138b34e99a9ac11b4402a966e7e4ba395b49bee9 /src/declarative/util/qmlpixmapcache.cpp
parent1337ed2a695e5d78cfde830f07877ff55a5b7051 (diff)
downloadQt-d363016a703f565432d2fd3d84cea4e179c79995.zip
Qt-d363016a703f565432d2fd3d84cea4e179c79995.tar.gz
Qt-d363016a703f565432d2fd3d84cea4e179c79995.tar.bz2
Add Image auto test
Also fix qmlpixmapcache error reporting and Image and BorderImage progress reporting for null images.
Diffstat (limited to 'src/declarative/util/qmlpixmapcache.cpp')
-rw-r--r--src/declarative/util/qmlpixmapcache.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/declarative/util/qmlpixmapcache.cpp b/src/declarative/util/qmlpixmapcache.cpp
index ba7895a..b8a9bd7 100644
--- a/src/declarative/util/qmlpixmapcache.cpp
+++ b/src/declarative/util/qmlpixmapcache.cpp
@@ -213,23 +213,34 @@ bool QmlPixmapCache::find(const QUrl& url, QPixmap *pixmap)
The returned QNetworkReply will be deleted when all get() calls are
matched by a corresponding find() call.
+
+ If the \a ok parameter is passed and \a url is a local file,
+ its value will be set to false if the pixmap could not be loaded;
+ otherwise the pixmap was loaded and *ok will be true.
*/
-QNetworkReply *QmlPixmapCache::get(QmlEngine *engine, const QUrl& url, QPixmap *pixmap)
+QNetworkReply *QmlPixmapCache::get(QmlEngine *engine, const QUrl& url, QPixmap *pixmap, bool *ok)
{
#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
QString lf = toLocalFileOrQrc(url);
if (!lf.isEmpty()) {
QString key = url.toString();
if (!QPixmapCache::find(key,pixmap)) {
+ bool loaded = true;
QFile f(lf);
if (f.open(QIODevice::ReadOnly)) {
if (!readImage(&f, pixmap)) {
qWarning() << "Format error loading" << url;
*pixmap = QPixmap();
+ loaded = false;
}
- } else
+ } else {
+ qWarning() << "Cannot open" << url;
*pixmap = QPixmap();
- QPixmapCache::insert(key, *pixmap);
+ loaded = false;
+ }
+ if (loaded)
+ QPixmapCache::insert(key, *pixmap);
+ if (ok) *ok = loaded;
}
return 0;
}