diff options
author | Misha Tyutyunik <Michael.Tyutyunik@nokia.com> | 2010-09-22 08:06:01 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2010-09-22 10:27:53 (GMT) |
commit | 5120dfec47475dd37f51df4dda9a4ef8494036ab (patch) | |
tree | fba6437e648e3e717ab536223100eb56078632c7 /src/network | |
parent | a9af4502e50bcbe80ff93fabb2da7f07a1dcf53b (diff) | |
download | Qt-5120dfec47475dd37f51df4dda9a4ef8494036ab.zip Qt-5120dfec47475dd37f51df4dda9a4ef8494036ab.tar.gz Qt-5120dfec47475dd37f51df4dda9a4ef8494036ab.tar.bz2 |
QNAM: Use QFileNetworkReply for qrc:/ URL schema
Resources do not need network access and can be quicker
loaded with QFileNetworkReply.
Reviewed-by: Markus Goetz
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/access/qfilenetworkreply.cpp | 5 | ||||
-rw-r--r-- | src/network/access/qnetworkaccessmanager.cpp | 4 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/network/access/qfilenetworkreply.cpp b/src/network/access/qfilenetworkreply.cpp index 4ac9a8c..00bd29e 100644 --- a/src/network/access/qfilenetworkreply.cpp +++ b/src/network/access/qfilenetworkreply.cpp @@ -97,7 +97,10 @@ QFileNetworkReply::QFileNetworkReply(QObject *parent, const QNetworkRequest &req QString fileName = url.toLocalFile(); if (fileName.isEmpty()) { - fileName = url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery); + if (url.scheme() == QLatin1String("qrc")) + fileName = QLatin1Char(':') + url.path(); + else + fileName = url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery); } QFileInfo fi(fileName); diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index b35c318..a637474 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -946,10 +946,10 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera // fast path for GET on file:// URLs // Also if the scheme is empty we consider it a file. - // The QNetworkAccessFileBackend will right now only be used - // for PUT or qrc:// + // The QNetworkAccessFileBackend will right now only be used for PUT if ((op == QNetworkAccessManager::GetOperation || op == QNetworkAccessManager::HeadOperation) && (req.url().scheme() == QLatin1String("file") + || req.url().scheme() == QLatin1String("qrc") || req.url().scheme().isEmpty())) { return new QFileNetworkReply(this, req, op); } |