diff options
author | Martin Jones <martin.jones@nokia.com> | 2011-05-12 14:34:48 +1000 |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2011-05-12 14:34:48 +1000 |
commit | 6fe601e4bcff790a335de949a20e223380ce9408 (patch) | |
tree | 85282c754696d8695bce57c362696d0164b15782 /src/declarative/util | |
parent | 57828fb1c1683bcf2a61c085e6143ce1498e7a78 (diff) |
Improve error message for invalid image provider name.
Also fix broken qdeclarativeimageprovider test.
Diffstat (limited to 'src/declarative/util')
-rw-r--r-- | src/declarative/util/qdeclarativepixmapcache.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp index f0e999b46e..ef0c422411 100644 --- a/src/declarative/util/qdeclarativepixmapcache.cpp +++ b/src/declarative/util/qdeclarativepixmapcache.cpp @@ -507,8 +507,19 @@ void QDeclarativePixmapReader::processJob(QDeclarativePixmapReply *runningJob, c QSize readSize; QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); QDeclarativeImageProvider::ImageType imageType = ep->getImageProviderType(url); - - if (imageType == QDeclarativeImageProvider::Image) { + if (imageType == QDeclarativeImageProvider::Invalid) { + QDeclarativePixmapReply::ReadError errorCode = QDeclarativePixmapReply::Loading; + QString errorStr = QDeclarativePixmap::tr("Invalid image provider: %1").arg(url.toString()); + QImage image; + mutex.lock(); + if (!cancelled.contains(runningJob)) { + if (sgContext) + runningJob->postReply(errorCode, errorStr, readSize, sgContext->createTexture(image), sgContext); + else + runningJob->postReply(errorCode, errorStr, readSize, image); + } + mutex.unlock(); + } else if (imageType == QDeclarativeImageProvider::Image) { QImage image = ep->getImageFromProvider(url, &readSize, requestSize); QDeclarativePixmapReply::ReadError errorCode = QDeclarativePixmapReply::NoError; QString errorStr; @@ -877,6 +888,9 @@ static QDeclarativePixmapData* createPixmapDataSync(QDeclarativeEngine *engine, QDeclarativeImageProvider::ImageType imageType = ep->getImageProviderType(url); switch (imageType) { + case QDeclarativeImageProvider::Invalid: + return new QDeclarativePixmapData(url, requestSize, + QDeclarativePixmap::tr("Invalid image provider: %1").arg(url.toString())); case QDeclarativeImageProvider::Texture: { QSGTexture *texture = ep->getTextureFromProvider(url, &readSize, requestSize); @@ -912,7 +926,7 @@ static QDeclarativePixmapData* createPixmapDataSync(QDeclarativeEngine *engine, } } - // no matching provider, or provider has bad image type, or provider returned null image + // provider has bad image type, or provider returned null image return new QDeclarativePixmapData(url, requestSize, QDeclarativePixmap::tr("Failed to get image from provider: %1").arg(url.toString())); } |