diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-05-07 09:59:06 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-05-07 10:09:44 (GMT) |
commit | 694822cbe757f2b742740f593319337127b04d17 (patch) | |
tree | 6f9e7f3dc26c291230f017a18f5d1207b145c406 /src | |
parent | 91337cb62bca653c9df7e8b8f43f451facc1efb8 (diff) | |
download | Qt-694822cbe757f2b742740f593319337127b04d17.zip Qt-694822cbe757f2b742740f593319337127b04d17.tar.gz Qt-694822cbe757f2b742740f593319337127b04d17.tar.bz2 |
QtDeclarative: avoid waiting for a network load on URIs with empty schemes.
The proper fix would be to have QNetworkAccessManager notify
immediately that this load cannot work (and it knows it can't
work). Then QtDeclarative can simply check what QNAM found.
Reviewed-By: Alan Alpert
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/qml/qdeclarativecompositetypemanager.cpp | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/declarative/qml/qdeclarativecompositetypemanager.cpp b/src/declarative/qml/qdeclarativecompositetypemanager.cpp index b0c9a43..625356c 100644 --- a/src/declarative/qml/qdeclarativecompositetypemanager.cpp +++ b/src/declarative/qml/qdeclarativecompositetypemanager.cpp @@ -360,7 +360,10 @@ void QDeclarativeCompositeTypeManager::loadResource(QDeclarativeCompositeTypeRes } else { resource->status = QDeclarativeCompositeTypeResource::Error; } + } else if (url.scheme().isEmpty()) { + // We can't open this, so just declare as an error + resource->status = QDeclarativeCompositeTypeResource::Error; } else { QNetworkReply *reply = @@ -382,27 +385,29 @@ void QDeclarativeCompositeTypeManager::loadSource(QDeclarativeCompositeTypeData if (file.open(QFile::ReadOnly)) { QByteArray data = file.readAll(); setData(unit, data, url); - } else { - QString errorDescription; - // ### - Fill in error - errorDescription = QLatin1String("File error for URL ") + url.toString(); - unit->status = QDeclarativeCompositeTypeData::Error; - // ### FIXME - QDeclarativeError error; - error.setDescription(errorDescription); - unit->errorType = QDeclarativeCompositeTypeData::AccessError; - unit->errors << error; - doComplete(unit); + return; // success } - - } else { + } else if (!url.scheme().isEmpty()) { QNetworkReply *reply = engine->networkAccessManager()->get(QNetworkRequest(url)); QObject::connect(reply, SIGNAL(finished()), this, SLOT(replyFinished())); QObject::connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(requestProgress(qint64,qint64))); + return; // waiting } + + // error happened + QString errorDescription; + // ### - Fill in error + errorDescription = QLatin1String("File error for URL ") + url.toString(); + unit->status = QDeclarativeCompositeTypeData::Error; + // ### FIXME + QDeclarativeError error; + error.setDescription(errorDescription); + unit->errorType = QDeclarativeCompositeTypeData::AccessError; + unit->errors << error; + doComplete(unit); } void QDeclarativeCompositeTypeManager::requestProgress(qint64 received, qint64 total) @@ -724,8 +729,10 @@ void QDeclarativeCompositeTypeManager::compile(QDeclarativeCompositeTypeData *un } } - QUrl importUrl = unit->imports.baseUrl().resolved(QUrl(QLatin1String("qmldir"))); - if (toLocalFileOrQrc(importUrl).isEmpty()) + QUrl importUrl; + if (!unit->imports.baseUrl().scheme().isEmpty()) + importUrl = unit->imports.baseUrl().resolved(QUrl(QLatin1String("qmldir"))); + if (!importUrl.scheme().isEmpty() && toLocalFileOrQrc(importUrl).isEmpty()) resourceList.prepend(importUrl); for (int ii = 0; ii < resourceList.count(); ++ii) { |