diff options
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/access/qnetworkaccessfilebackend.cpp | 11 | ||||
-rw-r--r-- | src/network/access/qnetworkaccessftpbackend.cpp | 2 | ||||
-rw-r--r-- | src/network/access/qnetworkaccessmanager.cpp | 11 | ||||
-rw-r--r-- | src/network/kernel/qhostinfo.cpp | 26 | ||||
-rw-r--r-- | src/network/kernel/qhostinfo_p.h | 7 | ||||
-rw-r--r-- | src/network/kernel/qhostinfo_unix.cpp | 2 | ||||
-rw-r--r-- | src/network/kernel/qhostinfo_win.cpp | 2 |
7 files changed, 17 insertions, 44 deletions
diff --git a/src/network/access/qnetworkaccessfilebackend.cpp b/src/network/access/qnetworkaccessfilebackend.cpp index 4560153..710c258 100644 --- a/src/network/access/qnetworkaccessfilebackend.cpp +++ b/src/network/access/qnetworkaccessfilebackend.cpp @@ -65,10 +65,15 @@ QNetworkAccessFileBackendFactory::create(QNetworkAccessManager::Operation op, } QUrl url = request.url(); - if (url.scheme() == QLatin1String("qrc") || !url.toLocalFile().isEmpty()) + if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0 || url.isLocalFile()) { return new QNetworkAccessFileBackend; - else if (!url.isEmpty() && url.authority().isEmpty()) { - // check if QFile could, in theory, open this URL + } else if (!url.scheme().isEmpty() && url.authority().isEmpty()) { + // check if QFile could, in theory, open this URL via the file engines + // it has to be in the format: + // prefix:path/to/file + // or prefix:/path/to/file + // + // this construct here must match the one below in open() QFileInfo fi(url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery)); if (fi.exists() || (op == QNetworkAccessManager::PutOperation && fi.dir().exists())) return new QNetworkAccessFileBackend; diff --git a/src/network/access/qnetworkaccessftpbackend.cpp b/src/network/access/qnetworkaccessftpbackend.cpp index 1a59011..da336d0 100644 --- a/src/network/access/qnetworkaccessftpbackend.cpp +++ b/src/network/access/qnetworkaccessftpbackend.cpp @@ -77,7 +77,7 @@ QNetworkAccessFtpBackendFactory::create(QNetworkAccessManager::Operation op, } QUrl url = request.url(); - if (url.scheme() == QLatin1String("ftp")) + if (url.scheme().compare(QLatin1String("ftp"), Qt::CaseInsensitive) == 0) return new QNetworkAccessFtpBackend; return 0; } diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 42c64fb..f7ada8c 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -935,21 +935,20 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera { Q_D(QNetworkAccessManager); + bool isLocalFile = req.url().isLocalFile(); + // 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:// if ((op == QNetworkAccessManager::GetOperation || op == QNetworkAccessManager::HeadOperation) - && (req.url().scheme() == QLatin1String("file") - || req.url().scheme().isEmpty())) { + && isLocalFile) { return new QFileNetworkReply(this, req, op); } #ifndef QT_NO_BEARERMANAGEMENT // Return a disabled network reply if network access is disabled. // Except if the scheme is empty or file://. - if (!d->networkAccessible && !(req.url().scheme() == QLatin1String("file") || - req.url().scheme().isEmpty())) { + if (!d->networkAccessible && !isLocalFile) { return new QDisabledNetworkReply(this, req, op); } @@ -991,7 +990,7 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera QUrl url = request.url(); QNetworkReplyImpl *reply = new QNetworkReplyImpl(this); #ifndef QT_NO_BEARERMANAGEMENT - if (req.url().scheme() != QLatin1String("file") && !req.url().scheme().isEmpty()) { + if (!isLocalFile) { connect(this, SIGNAL(networkSessionConnected()), reply, SLOT(_q_networkSessionConnected())); } diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index 8ae1305..985caf4 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -56,9 +56,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_THREAD Q_GLOBAL_STATIC(QHostInfoLookupManager, theHostInfoLookupManager) -#endif //#define QHOSTINFO_DEBUG @@ -87,10 +85,8 @@ Q_GLOBAL_STATIC(QHostInfoLookupManager, theHostInfoLookupManager) \snippet doc/src/snippets/code/src_network_kernel_qhostinfo.cpp 0 - The slot is invoked when the results are ready. (If you use - Qt for Embedded Linux and disabled multithreading support by defining - \c QT_NO_THREAD, lookupHost() will block until the lookup has - finished.) The results are stored in a QHostInfo object. Call + The slot is invoked when the results are ready. The results are + stored in a QHostInfo object. Call addresses() to get the list of IP addresses for the host, and hostName() to get the host name that was looked up. @@ -176,14 +172,6 @@ int QHostInfo::lookupHost(const QString &name, QObject *receiver, return id; } -#ifdef QT_NO_THREAD - QHostInfo hostInfo = QHostInfoAgent::fromName(name); - hostInfo.setLookupId(id); - QScopedPointer<QHostInfoResult> result(new QHostInfoResult); - QObject::connect(result.data(), SIGNAL(resultsReady(QHostInfo)), - receiver, member, Qt::QueuedConnection); - result.data()->emitResultsReady(hostInfo); -#else QHostInfoLookupManager *manager = theHostInfoLookupManager(); if (manager) { // the application is still alive @@ -204,8 +192,6 @@ int QHostInfo::lookupHost(const QString &name, QObject *receiver, QObject::connect(&runnable->resultEmitter, SIGNAL(resultsReady(QHostInfo)), receiver, member, Qt::QueuedConnection); manager->scheduleLookup(runnable); } -#endif - return id; } @@ -216,12 +202,7 @@ int QHostInfo::lookupHost(const QString &name, QObject *receiver, */ void QHostInfo::abortHostLookup(int id) { -#ifndef QT_NO_THREAD theHostInfoLookupManager()->abortLookup(id); -#else - // we cannot abort if it was non threaded.. the result signal has already been posted - Q_UNUSED(id); -#endif } /*! @@ -422,7 +403,6 @@ void QHostInfo::setErrorString(const QString &str) \sa hostName() */ -#ifndef QT_NO_THREAD QHostInfoRunnable::QHostInfoRunnable(QString hn, int i) : toBeLookedUp(hn), id(i) { setAutoDelete(true); @@ -747,6 +727,4 @@ void QHostInfoCache::clear() cache.clear(); } -#endif // QT_NO_THREAD - QT_END_NAMESPACE diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h index 85d14c2..134335f 100644 --- a/src/network/kernel/qhostinfo_p.h +++ b/src/network/kernel/qhostinfo_p.h @@ -60,8 +60,6 @@ #include "QtCore/qwaitcondition.h" #include "QtCore/qobject.h" #include "QtCore/qpointer.h" - -#ifndef QT_NO_THREAD #include "QtCore/qthread.h" #include "QtCore/qthreadpool.h" #include "QtCore/qmutex.h" @@ -70,7 +68,7 @@ #include "QtCore/qqueue.h" #include <QTime> #include <QCache> -#endif + QT_BEGIN_NAMESPACE @@ -112,7 +110,6 @@ public: int lookupId; }; -#ifndef QT_NO_THREAD // These functions are outside of the QHostInfo class and strictly internal. // Do NOT use them outside of QAbstractSocket. QHostInfo Q_NETWORK_EXPORT qt_qhostinfo_lookup(const QString &name, QObject *receiver, const char *member, bool *valid, int *id); @@ -192,8 +189,6 @@ private slots: void waitForThreadPoolDone() { threadPool.waitForDone(); } }; -#endif - QT_END_NAMESPACE #endif // QHOSTINFO_P_H diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp index 90751f4..0c8caa0 100644 --- a/src/network/kernel/qhostinfo_unix.cpp +++ b/src/network/kernel/qhostinfo_unix.cpp @@ -132,9 +132,7 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName) // Load res_init on demand. static volatile bool triedResolve = false; if (!triedResolve) { -#ifndef QT_NO_THREAD QMutexLocker locker(QMutexPool::globalInstanceGet(&local_res_init)); -#endif if (!triedResolve) { resolveLibrary(); triedResolve = true; diff --git a/src/network/kernel/qhostinfo_win.cpp b/src/network/kernel/qhostinfo_win.cpp index b30204b..65257e8 100644 --- a/src/network/kernel/qhostinfo_win.cpp +++ b/src/network/kernel/qhostinfo_win.cpp @@ -115,9 +115,7 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName) // Load res_init on demand. static volatile bool triedResolve = false; if (!triedResolve) { -#ifndef QT_NO_THREAD QMutexLocker locker(QMutexPool::globalInstanceGet(&local_getaddrinfo)); -#endif if (!triedResolve) { resolveLibrary(); triedResolve = true; |