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;
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);
}
}
- // 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()));
}
QTest::newRow(QTest::toString(id + " unknown provider"))
<< "image://bogus/exists.png" << "" << "" << QSize()
- << "file::2:1: QML Image: Failed to get image from provider: image://bogus/exists.png";
+ << "file::2:1: QML Image: Invalid image provider: image://bogus/exists.png";
}
void tst_qdeclarativeimageprovider::runTest(bool async, QDeclarativeImageProvider *provider)
// remove the provider and confirm
QString fileName = newImageFileName();
- QString error("file::2:1: QML Image: Failed to get image from provider: " + fileName);
+ QString error("file::2:1: QML Image: Invalid image provider: " + fileName);
QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
engine.removeImageProvider("test");